diff --git a/services/docstore/app/coffee/DocManager.coffee b/services/docstore/app/coffee/DocManager.coffee index a89d83e11c..61cd4a1be4 100644 --- a/services/docstore/app/coffee/DocManager.coffee +++ b/services/docstore/app/coffee/DocManager.coffee @@ -89,7 +89,7 @@ module.exports = DocManager = if err? || res.statusCode != 200 logger.err err:err, res:res, "something went wrong archiving doc in aws" callback(err) - MongoManager.markDocAsArchived doc._id, (error) -> + MongoManager.markDocAsArchived doc._id, doc.rev, (error) -> return callback(error) if error? callback() diff --git a/services/docstore/app/coffee/MongoManager.coffee b/services/docstore/app/coffee/MongoManager.coffee index 1f8b9ca6d8..f33e5995ef 100644 --- a/services/docstore/app/coffee/MongoManager.coffee +++ b/services/docstore/app/coffee/MongoManager.coffee @@ -28,14 +28,12 @@ module.exports = MongoManager = db.docs.update _id: ObjectId(doc_id), update, (err)-> callback(err) - markDocAsArchived: (doc_id, callback)-> + markDocAsArchived: (doc_id, rev, callback)-> update = $set: {} $unset: {} update.$set["inS3"] = true update.$unset["lines"] = true - # to ensure that the lines have not changed during the archive process - # what if we passed the lines through into the query {_id: doc_id, lines:lines} - # or more performant would be todo the rev {_id:doc_id, rev:rev} + # to ensure that the lines have not changed during the archive process we search via the rev db.docs.update _id: doc_id, update, (err)-> callback(err) \ No newline at end of file