diff --git a/services/web/app/coffee/Features/FileStore/FileStoreHandler.coffee b/services/web/app/coffee/Features/FileStore/FileStoreHandler.coffee index eb5c2cd03f..10545cca76 100644 --- a/services/web/app/coffee/Features/FileStore/FileStoreHandler.coffee +++ b/services/web/app/coffee/Features/FileStore/FileStoreHandler.coffee @@ -13,6 +13,9 @@ module.exports = FileStoreHandler = if err? logger.err err:err, project_id:project_id, file_id:file_id, fsPath:fsPath, "error stating file" callback(err) + if !stat? + logger.err project_id:project_id, file_id:file_id, fsPath:fsPath, "stat is not available, can not check file from disk" + return callback(new Error("error getting stat, not available")) if !stat.isFile() logger.log project_id:project_id, file_id:file_id, fsPath:fsPath, "tried to upload symlink, not contining" return callback(new Error("can not upload symlink")) diff --git a/services/web/test/UnitTests/coffee/FileStore/FileStoreHandlerTests.coffee b/services/web/test/UnitTests/coffee/FileStore/FileStoreHandlerTests.coffee index 7452c6fb79..01990787e1 100644 --- a/services/web/test/UnitTests/coffee/FileStore/FileStoreHandlerTests.coffee +++ b/services/web/test/UnitTests/coffee/FileStore/FileStoreHandlerTests.coffee @@ -96,6 +96,13 @@ describe "FileStoreHandler", -> @fs.createReadStream.called.should.equal false done() + describe "symlink", -> + it "should not read file stat returns nothing", (done)-> + @fs.lstat = sinon.stub().callsArgWith(1, null, null) + @handler.uploadFileFromDisk @project_id, @file_id, @fsPath, => + @fs.createReadStream.called.should.equal false + done() + describe "when upload fails", -> beforeEach -> @writeStream.on = (type, cb) ->