mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
[DocManager] optionally flush docs out of mongo when deleting them
This commit is contained in:
@@ -20,6 +20,7 @@ const logger = require('logger-sharelatex')
|
||||
const _ = require('underscore')
|
||||
const DocArchive = require('./DocArchiveManager')
|
||||
const RangeManager = require('./RangeManager')
|
||||
const Settings = require('settings-sharelatex')
|
||||
|
||||
module.exports = DocManager = {
|
||||
// TODO: For historical reasons, the doc version is currently stored in the docOps
|
||||
@@ -304,6 +305,19 @@ module.exports = DocManager = {
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
if (Settings.docstore.archiveOnSoftDelete) {
|
||||
// The user will not read this doc anytime soon. Flush it out of mongo.
|
||||
DocArchive.archiveDocById(project_id, doc_id, (err) => {
|
||||
if (err) {
|
||||
logger.warn(
|
||||
{ project_id, doc_id, err },
|
||||
'archiving a single doc in the background failed'
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return MongoManager.markDocAsDeleted(project_id, doc_id, callback)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user