added some missing error handling

This commit is contained in:
Henry Oswald 2015-09-08 16:33:45 +01:00
parent 17b0d99a65
commit 18d817ee0a

View file

@ -26,12 +26,15 @@ module.exports = DocArchiveManager =
archiveDocChanges: (project_id, doc_id, callback)->
MongoManager.getDocChangesCount doc_id, (error, count) ->
return callback(error) if error?
if count == 0
return callback()
else
MongoManager.getLastCompressedUpdate doc_id, (error, update) ->
return callback(error) if error?
MongoAWS.archiveDocHistory project_id, doc_id, (error) ->
logger.log doc_id:doc_id, error: error, "export to S3"
return callback(error) if error?
logger.log doc_id:doc_id, project_id:project_id, "exported document to S3"
MongoManager.markDocHistoryAsArchived doc_id, update, (error) ->
return callback(error) if error?
callback()
@ -48,11 +51,13 @@ module.exports = DocArchiveManager =
unArchiveDocChanges: (project_id, doc_id, callback)->
MongoManager.getArchivedDocChanges doc_id, (error, count) ->
return callback(error) if error?
if count == 0
return callback()
else
MongoAWS.unArchiveDocHistory project_id, doc_id, (error) ->
logger.log doc_id:doc_id, error: error, "import from S3"
return callback(error) if error?
logger.log doc_id:doc_id, project_id:project_id, "imported document from S3"
MongoManager.markDocHistoryAsUnarchived doc_id, (error) ->
return callback(error) if error?
callback()