Skip to content

Commit

Permalink
Graceful failure when S3 *(fake or real)* doesn't have key
Browse files Browse the repository at this point in the history
* Directly related to OpenUserJS#37. Stops net timeout when picking some other script that isn't present in fakeS3. Eventually when *aws-sdk* is updated this will be needed so it doesn't halt dev.

Possibly applicable routine to OpenUserJS#486 for inline live migration
  • Loading branch information
Martii committed Dec 6, 2014
1 parent cc99cac commit e2bca6d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions controllers/scriptStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,24 @@ exports.getSource = function (aReq, aCallback) {

Script.findOne({ installName: caseInsensitive(installName) },
function (aErr, aScript) {
var s3Object = null;

if (!aScript) {
return aCallback(null);
}

s3Object = s3.getObject({ Bucket: bucketName, Key: installName }).createReadStream().
on('error', function () {
if (isPro) {
console.error('S3 Key Not Found ' + installName);
}

return aCallback(null);
});

// Get the script
aCallback(aScript, s3.getObject({ Bucket: bucketName, Key: installName })
.createReadStream());
});
aCallback(aScript, s3Object);
});
};

exports.sendScript = function (aReq, aRes, aNext) {
Expand Down

0 comments on commit e2bca6d

Please sign in to comment.