|
@@ -14,8 +14,13 @@ ProjectLocator = require('./ProjectLocator')
|
|
|
SafePath = require './SafePath'
|
|
SafePath = require './SafePath'
|
|
|
|
|
|
|
|
wrapWithLock = (methodWithoutLock) ->
|
|
wrapWithLock = (methodWithoutLock) ->
|
|
|
|
|
+ # This lock is used whenever we read or write to an existing project's
|
|
|
|
|
+ # structure. Some operations to project structure cannot be done atomically
|
|
|
|
|
+ # in mongo, this lock is used to prevent reading the structure between two
|
|
|
|
|
+ # parts of a staged update.
|
|
|
methodWithLock = (project_id, args..., callback) ->
|
|
methodWithLock = (project_id, args..., callback) ->
|
|
|
- LockManager.mongoTransactionLock.runWithLock project_id,
|
|
|
|
|
|
|
+ lockKey = ProjectEntityMongoUpdateHandler.getProjectMongoLockKey project_id
|
|
|
|
|
+ LockManager.runWithLock lockKey,
|
|
|
(cb) -> methodWithoutLock project_id, args..., cb
|
|
(cb) -> methodWithoutLock project_id, args..., cb
|
|
|
callback
|
|
callback
|
|
|
methodWithLock.withoutLock = methodWithoutLock
|
|
methodWithLock.withoutLock = methodWithoutLock
|
|
@@ -161,6 +166,9 @@ module.exports = ProjectEntityMongoUpdateHandler = self =
|
|
|
return callback(err)
|
|
return callback(err)
|
|
|
callback null, folder, parentFolder_id
|
|
callback null, folder, parentFolder_id
|
|
|
|
|
|
|
|
|
|
+ getProjectMongoLockKey: (project_id) ->
|
|
|
|
|
+ "lock:web:mongoTransaction:{#{project_id}}"
|
|
|
|
|
+
|
|
|
_removeElementFromMongoArray: (model, model_id, path, callback = (err, project) ->)->
|
|
_removeElementFromMongoArray: (model, model_id, path, callback = (err, project) ->)->
|
|
|
conditions = {_id:model_id}
|
|
conditions = {_id:model_id}
|
|
|
update = {"$unset":{}}
|
|
update = {"$unset":{}}
|