From 2a23082c4e899dfa89ffd0e5f82893d644838c4f Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Tue, 26 Sep 2017 09:48:09 +0100 Subject: [PATCH] remove stat test for missing files --- .../app/coffee/ResourceStateManager.coffee | 23 ++++--------------- .../coffee/ResourceStateManagerTests.coffee | 15 ------------ 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/services/clsi/app/coffee/ResourceStateManager.coffee b/services/clsi/app/coffee/ResourceStateManager.coffee index e250e6447c..fbd4c67736 100644 --- a/services/clsi/app/coffee/ResourceStateManager.coffee +++ b/services/clsi/app/coffee/ResourceStateManager.coffee @@ -4,7 +4,6 @@ logger = require "logger-sharelatex" settings = require("settings-sharelatex") Errors = require "./Errors" SafeReader = require "./SafeReader" -async = require "async" module.exports = ResourceStateManager = @@ -61,21 +60,9 @@ module.exports = ResourceStateManager = seenFile = {} for file in allFiles seenFile[file] = true - missingFileCandidates = (resource.path for resource in resources when not seenFile[resource.path]) - # now check if they are really missing - ResourceStateManager._checkMissingFiles missingFileCandidates, basePath, (missingFiles) -> - if missingFiles?.length > 0 - logger.err missingFiles:missingFiles, basePath:basePath, allFiles:allFiles, resources:resources, "missing input files for project" - return callback new Errors.FilesOutOfSyncError("resource files missing in incremental update") - else - callback() - - _checkMissingFiles: (missingFileCandidates, basePath, callback = (missingFiles) ->) -> - if missingFileCandidates.length > 0 - fileDoesNotExist = (file, cb) -> - fs.stat Path.join(basePath, file), (err) -> - logger.log file:file, err:err, result: err?, "stating potential missing file" - cb(err?) - async.filterSeries missingFileCandidates, fileDoesNotExist, callback + missingFiles = (resource.path for resource in resources when not seenFile[resource.path]) + if missingFiles?.length > 0 + logger.err missingFiles:missingFiles, basePath:basePath, allFiles:allFiles, resources:resources, "missing input files for project" + return callback new Errors.FilesOutOfSyncError("resource files missing in incremental update") else - callback([]) + callback() diff --git a/services/clsi/test/unit/coffee/ResourceStateManagerTests.coffee b/services/clsi/test/unit/coffee/ResourceStateManagerTests.coffee index 6c55a1d0be..e5e1c13011 100644 --- a/services/clsi/test/unit/coffee/ResourceStateManagerTests.coffee +++ b/services/clsi/test/unit/coffee/ResourceStateManagerTests.coffee @@ -88,27 +88,12 @@ describe "ResourceStateManager", -> it "should call the callback", -> @callback.calledWithExactly().should.equal true - describe "when there is a file missing from the outputFileFinder but present on disk", -> - beforeEach -> - @allFiles = [ @resources[0].path, @resources[1].path] - @fs.stat = sinon.stub().callsArg(1) - @ResourceStateManager.checkResourceFiles(@resources, @allFiles, @basePath, @callback) - - it "should stat the file to see if it is present", -> - @fs.stat.called.should.equal true - - it "should call the callback", -> - @callback.calledWithExactly().should.equal true - describe "when there is a missing file", -> beforeEach -> @allFiles = [ @resources[0].path, @resources[1].path] @fs.stat = sinon.stub().callsArgWith(1, new Error()) @ResourceStateManager.checkResourceFiles(@resources, @allFiles, @basePath, @callback) - it "should stat the file to see if it is present", -> - @fs.stat.called.should.equal true - it "should call the callback with an error", -> error = new Errors.FilesOutOfSyncError("resource files missing in incremental update") @callback.calledWith(error).should.equal true