Skip to content

Commit

Permalink
[Fix] Archive path may be upper dir of the root dir
Browse files Browse the repository at this point in the history
  • Loading branch information
efeiefei committed Apr 21, 2017
1 parent 375be28 commit 8005160
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ FMApp.controller('FileManagerCtr', ['$scope', '$http', '$location',
if (!archive.match(/\.zip$/)) {
archive += '.zip';
}
var url = 'api' + FM.curFolderPath;
var url = 'api' + FM.curFolderPath + archive;
var src = FM.selection.map(function (file) {
return file.relPath;
});
httpRequest('PUT', url, {type: 'ARCHIVE'}, {src: src, archive: archive, dirs: FM.archiveEmbedDirs});
httpRequest('POST', url, {type: 'CREATE_ARCHIVE'}, {src: src, embedDirs: FM.archiveEmbedDirs});
};

FM.rename = function (newName) {
Expand Down
15 changes: 7 additions & 8 deletions lib/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,13 @@ router.put('/api/(.*)', Tools.loadRealPath, Tools.checkPathExists, bodyParser(),
yield * FileManager.rename(p, FilePath(target));
this.body = 'Rename Succeed!';
}
else if (type === 'ARCHIVE') {
var src = this.request.body.src;
var archive = (p === '.' ? '' : p) + this.request.body.archive;
if (!src) return this.status = 400;
yield * FileManager.archive(C.data.root, archive, src, !!this.request.body.dirs);
this.body = 'Create Archive Succeed!';
}
else {
this.status = 400;
this.body = 'Arg Type Error!';
}
});

router.post('/api/(.*)', Tools.loadRealPath, Tools.checkPathNotExists, function *() {
router.post('/api/(.*)', Tools.loadRealPath, Tools.checkPathNotExists, bodyParser(), function *() {
var type = this.query.type;
var p = this.request.fPath;
if (!type) {
Expand All @@ -97,6 +90,12 @@ router.post('/api/(.*)', Tools.loadRealPath, Tools.checkPathNotExists, function
this.body = 'Lack Upload File!';
}
}
else if (type === 'CREATE_ARCHIVE') {
var src = this.request.body.src;
if (!src) return this.status = 400;
yield * FileManager.archive(C.data.root, p, src, !!this.request.body.embedDirs);
this.body = 'Create Archive Succeed!';
}
else {
this.status = 400;
this.body = 'Arg Type Error!';
Expand Down

0 comments on commit 8005160

Please sign in to comment.