mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
prevent double archiving by checking if any inS3 field is already present
This commit is contained in:
parent
e49f260507
commit
847a553344
2 changed files with 18 additions and 13 deletions
|
@ -36,20 +36,25 @@ module.exports = DocArchiveManager =
|
|||
logger.log {project_id, doc_id}, "document history is empty, not archiving"
|
||||
return callback()
|
||||
else
|
||||
MongoManager.getLastCompressedUpdate doc_id, (error, update) ->
|
||||
MongoManager.getArchivedDocChanges doc_id, (error, count) ->
|
||||
return callback(error) if error?
|
||||
MongoManager.markDocHistoryAsArchiveInProgress doc_id, update, (error) ->
|
||||
if count != 0
|
||||
logger.log {project_id, doc_id}, "document history contains archived entries, not archiving"
|
||||
return callback()
|
||||
MongoManager.getLastCompressedUpdate doc_id, (error, update) ->
|
||||
return callback(error) if error?
|
||||
MongoAWS.archiveDocHistory project_id, doc_id, (error) ->
|
||||
if error?
|
||||
MongoManager.clearDocHistoryAsArchiveInProgress doc_id, update, (err) ->
|
||||
return callback(err) if err?
|
||||
callback(error)
|
||||
else
|
||||
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()
|
||||
MongoManager.markDocHistoryAsArchiveInProgress doc_id, update, (error) ->
|
||||
return callback(error) if error?
|
||||
MongoAWS.archiveDocHistory project_id, doc_id, (error) ->
|
||||
if error?
|
||||
MongoManager.clearDocHistoryAsArchiveInProgress doc_id, update, (err) ->
|
||||
return callback(err) if err?
|
||||
callback(error)
|
||||
else
|
||||
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()
|
||||
|
||||
unArchiveAllDocsChanges: (project_id, callback = (error, docs) ->) ->
|
||||
DocstoreHandler.getAllDocs project_id, (error, docs) ->
|
||||
|
|
|
@ -144,7 +144,7 @@ module.exports = MongoManager =
|
|||
db.docHistory.count { doc_id : ObjectId(doc_id.toString()), inS3 : { $exists : false }}, {}, callback
|
||||
|
||||
getArchivedDocChanges: (doc_id, callback)->
|
||||
db.docHistory.count { doc_id: ObjectId(doc_id.toString()) , inS3: true }, {}, callback
|
||||
db.docHistory.count { doc_id: ObjectId(doc_id.toString()) , inS3: { $exists: true }}, {}, callback
|
||||
|
||||
markDocHistoryAsArchiveInProgress: (doc_id, update, callback) ->
|
||||
db.docHistory.update { _id: update._id }, { $set : { inS3 : false } }, callback
|
||||
|
|
Loading…
Reference in a new issue