mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-27 02:51:57 +02:00
null check stat when we check file on disk
https://sentry.io/sharelatex-1/sl-web-server-prod/issues/125814174/
This commit is contained in:
@@ -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"))
|
||||
|
||||
@@ -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) ->
|
||||
|
||||
Reference in New Issue
Block a user