mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
handle auto unarchive track changes
This commit is contained in:
@@ -11,6 +11,8 @@ thirtySeconds = 30 * 1000
|
||||
module.exports = DocArchiveManager =
|
||||
|
||||
archiveAllDocsChanges: (project_id, callback = (error, docs) ->) ->
|
||||
if settings.filestore?.backend != "s3"
|
||||
return callback(null)
|
||||
MongoManager.getProjectsDocs project_id, (error, docs) ->
|
||||
if error?
|
||||
return callback(error)
|
||||
@@ -33,6 +35,8 @@ module.exports = DocArchiveManager =
|
||||
callback()
|
||||
|
||||
unArchiveAllDocsChanges: (project_id, callback = (error, docs) ->) ->
|
||||
if settings.filestore?.backend != "s3"
|
||||
return callback(null)
|
||||
MongoManager.getProjectsDocs project_id, (error, docs) ->
|
||||
if error?
|
||||
return callback(error)
|
||||
@@ -43,7 +47,7 @@ module.exports = DocArchiveManager =
|
||||
async.series jobs, callback
|
||||
|
||||
unArchiveDocChanges: (project_id, doc_id, callback)->
|
||||
MongoManager.getDocChangesCount doc_id, (error, count) ->
|
||||
MongoManager.getArchivedDocChanges doc_id, (error, count) ->
|
||||
if count == 0
|
||||
return callback()
|
||||
else
|
||||
|
||||
@@ -47,6 +47,7 @@ module.exports = MongoManager =
|
||||
|
||||
|
||||
insertCompressedUpdate: (project_id, doc_id, update, temporary, callback = (error) ->) ->
|
||||
inS3 = update.inS3?
|
||||
update = {
|
||||
doc_id: ObjectId(doc_id.toString())
|
||||
project_id: ObjectId(project_id.toString())
|
||||
@@ -54,6 +55,9 @@ module.exports = MongoManager =
|
||||
meta: update.meta
|
||||
v: update.v
|
||||
}
|
||||
if inS3?
|
||||
update.inS3 = true
|
||||
|
||||
if temporary
|
||||
seconds = 1000
|
||||
minutes = 60 * seconds
|
||||
@@ -117,7 +121,7 @@ module.exports = MongoManager =
|
||||
db.docHistory.ensureIndex { project_id: 1, "meta.end_ts": 1 }, { background: true }
|
||||
# For finding all packs that affect a project (use a sparse index so only packs are included)
|
||||
db.docHistory.ensureIndex { project_id: 1, "pack.0.meta.end_ts": 1, "meta.end_ts": 1}, { background: true, sparse: true }
|
||||
# For finding updates that don't yet have a project_id and need it inserting
|
||||
# For finding updates that dont yet have a project_id and need it inserting
|
||||
db.docHistory.ensureIndex { doc_id: 1, project_id: 1 }, { background: true }
|
||||
# For finding project meta-data
|
||||
db.projectHistoryMetaData.ensureIndex { project_id: 1 }, { background: true }
|
||||
@@ -133,6 +137,9 @@ module.exports = MongoManager =
|
||||
getDocChangesCount: (doc_id, callback)->
|
||||
db.docHistory.count doc_id: ObjectId(doc_id.toString()), {}, callback
|
||||
|
||||
getArchivedDocChanges: (doc_id, callback)->
|
||||
db.docHistory.count { doc_id: ObjectId(doc_id.toString()) , inS3: true }, {}, callback
|
||||
|
||||
markDocHistoryAsArchived: (doc_id, callback)->
|
||||
MongoManager.getLastCompressedUpdate doc_id, (error, update) ->
|
||||
db.docHistory.update { _id: update._id }, { $set : { inS3 : true } }, (error)->
|
||||
|
||||
@@ -6,6 +6,7 @@ WebApiManager = require "./WebApiManager"
|
||||
UpdateTrimmer = require "./UpdateTrimmer"
|
||||
logger = require "logger-sharelatex"
|
||||
async = require "async"
|
||||
DocArchiveManager = require "./DocArchiveManager"
|
||||
|
||||
module.exports = UpdatesManager =
|
||||
compressAndSaveRawUpdates: (project_id, doc_id, rawUpdates, temporary, callback = (error) ->) ->
|
||||
@@ -94,7 +95,9 @@ module.exports = UpdatesManager =
|
||||
getProjectUpdates: (project_id, options = {}, callback = (error, updates) ->) ->
|
||||
UpdatesManager.processUncompressedUpdatesForProject project_id, (error) ->
|
||||
return callback(error) if error?
|
||||
MongoManager.getProjectUpdates project_id, options, callback
|
||||
DocArchiveManager.unArchiveAllDocsChanges project_id, (error) ->
|
||||
return callback(error,null) if error?
|
||||
MongoManager.getProjectUpdates project_id, options, callback
|
||||
|
||||
getProjectUpdatesWithUserInfo: (project_id, options = {}, callback = (error, updates) ->) ->
|
||||
UpdatesManager.getProjectUpdates project_id, options, (error, updates) ->
|
||||
|
||||
Reference in New Issue
Block a user