diff --git a/services/clsi/app/coffee/OutputFileFinder.coffee b/services/clsi/app/coffee/OutputFileFinder.coffee index 8ef06b6bba..fbfd38ed55 100644 --- a/services/clsi/app/coffee/OutputFileFinder.coffee +++ b/services/clsi/app/coffee/OutputFileFinder.coffee @@ -47,9 +47,8 @@ module.exports = OutputFileFinder = proc.on "error", callback proc.on "close", (code) -> if code != 0 - error = new Error("find returned non-zero exit code: #{code}") - return callback(error) - + logger.warn {directory, code}, "find returned error, directory likely doesn't exist" + return callback null, [] fileList = stdout.trim().split("\n") fileList = fileList.map (file) -> # Strip leading directory diff --git a/services/clsi/test/unit/coffee/OutputFileFinderTests.coffee b/services/clsi/test/unit/coffee/OutputFileFinderTests.coffee index 6acddf6bd8..46d8c1fc42 100644 --- a/services/clsi/test/unit/coffee/OutputFileFinderTests.coffee +++ b/services/clsi/test/unit/coffee/OutputFileFinderTests.coffee @@ -11,7 +11,7 @@ describe "OutputFileFinder", -> @OutputFileFinder = SandboxedModule.require modulePath, requires: "fs": @fs = {} "child_process": spawn: @spawn = sinon.stub() - "logger-sharelatex": { log: sinon.stub() } + "logger-sharelatex": { log: sinon.stub(), warn: sinon.stub() } @directory = "/test/dir" @callback = sinon.stub() @@ -43,15 +43,26 @@ describe "OutputFileFinder", -> @directory = "/base/dir" @OutputFileFinder._getAllFiles @directory, @callback - @proc.stdout.emit( - "data", - ["/base/dir/main.tex", "/base/dir/chapters/chapter1.tex"].join("\n") + "\n" - ) - @proc.emit "close", 0 - - it "should call the callback with the relative file paths", -> - @callback.calledWith( - null, - ["main.tex", "chapters/chapter1.tex"] - ).should.equal true - + describe "successfully", -> + beforeEach -> + @proc.stdout.emit( + "data", + ["/base/dir/main.tex", "/base/dir/chapters/chapter1.tex"].join("\n") + "\n" + ) + @proc.emit "close", 0 + + it "should call the callback with the relative file paths", -> + @callback.calledWith( + null, + ["main.tex", "chapters/chapter1.tex"] + ).should.equal true + + describe "when the directory doesn't exist", -> + beforeEach -> + @proc.emit "close", 1 + + it "should call the callback with a blank array", -> + @callback.calledWith( + null, + [] + ).should.equal true