mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-31 19:54:25 +00:00
use syncType and syncState for clsi state options
This commit is contained in:
parent
da86a094a8
commit
d4aad06c1f
2 changed files with 14 additions and 14 deletions
|
@ -31,11 +31,11 @@ module.exports = RequestParser =
|
|||
response.check = @_parseAttribute "check",
|
||||
compile.options.check,
|
||||
type: "string"
|
||||
response.incremental = @_parseAttribute "incremental",
|
||||
compile.options.incremental,
|
||||
response.syncType = @_parseAttribute "syncType",
|
||||
compile.options.syncType,
|
||||
type: "string"
|
||||
response.state = @_parseAttribute "state",
|
||||
compile.options.state,
|
||||
response.syncState = @_parseAttribute "syncState",
|
||||
compile.options.syncState,
|
||||
type: "string"
|
||||
|
||||
if response.timeout > RequestParser.MAX_TIMEOUT
|
||||
|
|
|
@ -13,23 +13,23 @@ parallelFileDownloads = settings.parallelFileDownloads or 1
|
|||
module.exports = ResourceWriter =
|
||||
|
||||
syncResourcesToDisk: (request, basePath, callback = (error) ->) ->
|
||||
if request.incremental?
|
||||
ResourceWriter.checkState request.incremental, basePath, (error, ok) ->
|
||||
logger.log state: request.state, result:ok, "checked state on incremental request"
|
||||
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
|
||||
ResourceWriter.saveIncrementalResourcesToDisk request.project_id, request.resources, basePath, callback
|
||||
else
|
||||
@saveAllResourcesToDisk request.project_id, request.resources, basePath, (error) ->
|
||||
return callback(error) if error?
|
||||
ResourceWriter.storeState request.state, basePath, callback
|
||||
ResourceWriter.storeSyncState request.syncState, basePath, callback
|
||||
|
||||
storeState: (state, basePath, callback) ->
|
||||
logger.log state:state, basePath:basePath, "writing state"
|
||||
fs.writeFile Path.join(basePath, ".resource-state"), state, {encoding: 'ascii'}, callback
|
||||
storeSyncState: (state, basePath, callback) ->
|
||||
logger.log state:state, basePath:basePath, "writing sync state"
|
||||
fs.writeFile Path.join(basePath, ".resource-sync-state"), state, {encoding: 'ascii'}, callback
|
||||
|
||||
checkState: (state, basePath, callback) ->
|
||||
fs.readFile Path.join(basePath, ".resource-state"), {encoding:'ascii'}, (err, oldState) ->
|
||||
logger.log state:state, oldState: oldState, basePath:basePath, err:err, "checking state"
|
||||
checkSyncState: (state, basePath, callback) ->
|
||||
fs.readFile Path.join(basePath, ".resource-sync-state"), {encoding:'ascii'}, (err, oldState) ->
|
||||
logger.log state:state, oldState: oldState, basePath:basePath, err:err, "checking sync state"
|
||||
if state is oldState
|
||||
return callback(null, true)
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue