Browse Source

point where we unset doc lines also search on doc rev to make sure
the document has not been updated

Henry Oswald 11 years ago
parent
commit
ea92f57acc

+ 1 - 1
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()
 

+ 2 - 4
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)