mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-05 09:00:07 +00:00
increment project version on every structure change
This commit is contained in:
parent
470d67a3aa
commit
67d784a74a
3 changed files with 5 additions and 4 deletions
|
@ -255,7 +255,7 @@ module.exports = ProjectEntityMongoUpdateHandler = self =
|
|||
update["$push"][mongopath] = element
|
||||
# we need to increment the project version number for any structure change
|
||||
update["$inc"]["version"] = 1 # increment project version number
|
||||
logger.log project_id: project._id, element_id: element._id, fileType: type, folder_id: folder_id, mongopath:mongopath, update: update, "adding element to project"
|
||||
logger.log project_id: project._id, element_id: element._id, fileType: type, folder_id: folder_id, mongopath:mongopath, "adding element to project"
|
||||
Project.findOneAndUpdate conditions, update, {"new": true}, (err, newProject)->
|
||||
if err?
|
||||
logger.err err: err, project_id: project._id, 'error saving in putElement project'
|
||||
|
|
|
@ -22,6 +22,7 @@ ProjectSchema = new Schema
|
|||
readOnly_refs : [ type:ObjectId, ref:'User' ]
|
||||
rootDoc_id : {type: ObjectId}
|
||||
rootFolder : [FolderSchema]
|
||||
version : {type: Number}
|
||||
publicAccesLevel : {type: String, default: 'private'}
|
||||
compiler : {type:String, default:'pdflatex'}
|
||||
spellCheckLanguage : {type:String, default:'en'}
|
||||
|
|
|
@ -117,7 +117,7 @@ describe 'ProjectEntityMongoUpdateHandler', ->
|
|||
.calledWith(
|
||||
{ _id: project_id },
|
||||
{
|
||||
'$inc': { 'file.png.rev': 1 }
|
||||
'$inc': { 'file.png.rev': 1, 'version': 1 }
|
||||
'$set': { 'file.png.created': new Date() }
|
||||
}
|
||||
{}
|
||||
|
@ -324,7 +324,7 @@ describe 'ProjectEntityMongoUpdateHandler', ->
|
|||
@ProjectModel.findOneAndUpdate
|
||||
.calledWith(
|
||||
{ _id: project_id },
|
||||
{ $set: { "mongo.path.name": @newName } },
|
||||
{ $set: { "mongo.path.name": @newName }, $inc: {"version": 1} },
|
||||
{ new: true }
|
||||
).should.equal true
|
||||
|
||||
|
@ -384,7 +384,7 @@ describe 'ProjectEntityMongoUpdateHandler', ->
|
|||
|
||||
it 'should pull', ->
|
||||
@ProjectModel.findOneAndUpdate
|
||||
.calledWith({ _id: @id }, { '$pull': { 'folders[0]': null } }, {'new': true})
|
||||
.calledWith({ _id: @id }, { '$pull': { 'folders[0]': null }, '$inc': {'version': 1} }, {'new': true})
|
||||
.should.equal true
|
||||
|
||||
it 'should call the callback', ->
|
||||
|
|
Loading…
Reference in a new issue