Skip to content

Commit f1c69fe

Browse files
committed
Merge pull request #487 from Martii/gracefulFailureTrap
Graceful failure when S3 *(fake or real)* doesn't have key Auto-merge
2 parents cc99cac + e2bca6d commit f1c69fe

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

controllers/scriptStorage.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,24 @@ exports.getSource = function (aReq, aCallback) {
5050

5151
Script.findOne({ installName: caseInsensitive(installName) },
5252
function (aErr, aScript) {
53+
var s3Object = null;
54+
5355
if (!aScript) {
5456
return aCallback(null);
5557
}
5658

59+
s3Object = s3.getObject({ Bucket: bucketName, Key: installName }).createReadStream().
60+
on('error', function () {
61+
if (isPro) {
62+
console.error('S3 Key Not Found ' + installName);
63+
}
64+
65+
return aCallback(null);
66+
});
67+
5768
// Get the script
58-
aCallback(aScript, s3.getObject({ Bucket: bucketName, Key: installName })
59-
.createReadStream());
60-
});
69+
aCallback(aScript, s3Object);
70+
});
6171
};
6272

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

0 commit comments

Comments
 (0)