added files out of sync error object

This commit is contained in:
Brian Gough 2017-08-03 15:56:59 +01:00
parent d4aad06c1f
commit 44ae011703
3 changed files with 11 additions and 2 deletions

View file

@ -4,6 +4,7 @@ Settings = require "settings-sharelatex"
Metrics = require "./Metrics"
ProjectPersistenceManager = require "./ProjectPersistenceManager"
logger = require "logger-sharelatex"
Errors = require "./Errors"
module.exports = CompileController =
compile: (req, res, next = (error) ->) ->
@ -15,7 +16,7 @@ module.exports = CompileController =
ProjectPersistenceManager.markProjectAsJustAccessed request.project_id, (error) ->
return next(error) if error?
CompileManager.doCompile request, (error, outputFiles = []) ->
if error?.message is "invalid state"
if error instanceOf Errors.FilesOutOfSyncError
code = 409 # Http 409 Conflict
status = "retry"
else if error?.terminated

View file

@ -5,6 +5,13 @@ NotFoundError = (message) ->
return error
NotFoundError.prototype.__proto__ = Error.prototype
FilesOutOfSyncError = (message) ->
error = new Error(message)
error.name = "FilesOutOfSyncError"
error.__proto__ = FilesOutOfSyncError.prototype
return error
FilesOutOfSyncError.prototype.__proto__ = Error.prototype
module.exports = Errors =
NotFoundError: NotFoundError
FilesOutOfSyncError: FilesOutOfSyncError

View file

@ -5,6 +5,7 @@ async = require "async"
mkdirp = require "mkdirp"
OutputFileFinder = require "./OutputFileFinder"
Metrics = require "./Metrics"
Errors = require "./Errors"
logger = require "logger-sharelatex"
settings = require("settings-sharelatex")
@ -16,7 +17,7 @@ module.exports = ResourceWriter =
if request.syncType? is "incremental"
ResourceWriter.checkSyncState request.syncState, basePath, (error, ok) ->
logger.log syncState: request.syncState, result:ok, "checked state on incremental request"
return callback new Error("invalid state") if not ok
return callback new Errors.FilesOutOfSyncError("invalid state for incremental update") if not ok
ResourceWriter.saveIncrementalResourcesToDisk request.project_id, request.resources, basePath, callback
else
@saveAllResourcesToDisk request.project_id, request.resources, basePath, (error) ->