Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 521767 - Sending bad project move request throws exception rather…
… than return 403
  • Loading branch information
mrennie committed Sep 11, 2017
1 parent a8bb056 commit d1a3fec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
21 changes: 13 additions & 8 deletions modules/orionode/lib/fileUtil.js
Expand Up @@ -437,7 +437,7 @@ exports.handleFilePOST = function(workspaceRoot, fileRoot, req, res, destFile, m
return writeFileMetadata(req, res, api.join(fileRoot, destFile.workspaceId), api.join(workspaceRoot, destFile.workspaceId), destFile, stats, /*etag*/null, /*depth*/0, metadataMixins);
})
.catch(function(err) {
api.writeError(500, res, err.message);
return api.writeError(err.code || 500, res, err.message);
});
};
return fs.statAsync(destFile.path)
Expand Down Expand Up @@ -472,19 +472,24 @@ exports.handleFilePOST = function(workspaceRoot, fileRoot, req, res, destFile, m
});
} else {
return fs.renameAsync(sourceFile.path, destFile.path)
.then(function(result) {
var eventData = { type: "rename", isDir: stats.isDirectory(), file: destFile, sourceFile: sourceFile };
exports.fireFileModificationEvent(eventData);
return result;
});
.then(function(result) {
var eventData = { type: "rename", isDir: stats.isDirectory(), file: destFile, sourceFile: sourceFile };
exports.fireFileModificationEvent(eventData);
return result;
})
.catch(function rejectRename(err) {
var err = new Error("Failed to move project: "+sourceUrl)
err.code = 403;
throw err;
});
}
})
.then(writeResponse.bind(null, destExists))
.catch(function(err) {
if (err.code === 'ENOENT') {
return api.writeError(404, res, 'File not found:' + sourceUrl);
return api.writeError(err.code || 404, res, 'File not found:' + sourceUrl);
}
return api.writeError(500, res, err);
return api.writeError(err.code || 500, res, err);
});
}
// Just a regular file write
Expand Down
16 changes: 8 additions & 8 deletions modules/orionode/lib/workspace.js
Expand Up @@ -151,15 +151,15 @@ module.exports = function(options) {

if(store.createRenameDeleteProject) {
return store.createRenameDeleteProject(workspace.id, {projectName:projectName, contentLocation:file.path, originalPath: req.body.Location})
.then(function(){
return fileUtil.handleFilePOST(workspaceRoot, fileRoot, req, res, file, {
Id: projectName,
ContentLocation: projectLocation,
Location: projectLocation
.then(function(){
return fileUtil.handleFilePOST(workspaceRoot, fileRoot, req, res, file, {
Id: projectName,
ContentLocation: projectLocation,
Location: projectLocation
});
}).catch(function(err){
writeError(err.code || 500, res, err);
});
}).catch(function(err){
writeError(err.code || 500, res, err);
});
}
return fileUtil.handleFilePOST(workspaceRoot, fileRoot, req, res, file, {
Id: projectName,
Expand Down

0 comments on commit d1a3fec

Please sign in to comment.