From 6c0665bb49f623cb4eaafcaed1709f65dc5fc105 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Wed, 22 Aug 2018 21:32:19 +0100 Subject: [PATCH] change sync to async for lockfile debugging --- services/clsi/app/coffee/LockManager.coffee | 18 ++++++++++-------- .../test/unit/coffee/LockManagerTests.coffee | 2 ++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/services/clsi/app/coffee/LockManager.coffee b/services/clsi/app/coffee/LockManager.coffee index 2877d5f97d..069e26b2ad 100644 --- a/services/clsi/app/coffee/LockManager.coffee +++ b/services/clsi/app/coffee/LockManager.coffee @@ -16,11 +16,13 @@ module.exports = LockManager = stale: @LOCK_STALE Lockfile.lock path, lockOpts, (error) -> return callback new Errors.AlreadyCompilingError("compile in progress") if error?.code is 'EEXIST' - if error? - logger.err error:error, path:path, statLock:fs.lstatSync(path), statDir: fs.lstatSync(path.dirname(path)), "unable to get lock" - return callback(error) - runner (error1, args...) -> - Lockfile.unlock path, (error2) -> - error = error1 or error2 - return callback(error) if error? - callback(null, args...) + fs.lstat path, (err, statLock)-> + fs.lstat Path.dirname(path), (err, statDir)-> + if error? + logger.err error:error, path:path, statLock:statLock, statDir: statDir, "unable to get lock" + return callback(error) + runner (error1, args...) -> + Lockfile.unlock path, (error2) -> + error = error1 or error2 + return callback(error) if error? + callback(null, args...) diff --git a/services/clsi/test/unit/coffee/LockManagerTests.coffee b/services/clsi/test/unit/coffee/LockManagerTests.coffee index 2d0c95afa1..ab9ce9385c 100644 --- a/services/clsi/test/unit/coffee/LockManagerTests.coffee +++ b/services/clsi/test/unit/coffee/LockManagerTests.coffee @@ -10,6 +10,8 @@ describe "DockerLockManager", -> @LockManager = SandboxedModule.require modulePath, requires: "settings-sharelatex": {} "logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() } + "fs": + lstat:sinon.stub().callsArgWith(1) "lockfile": @Lockfile = {} @lockFile = "/local/compile/directory/.project-lock"