mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
23 lines
904 B
CoffeeScript
23 lines
904 B
CoffeeScript
MongoManager = require "./MongoManager"
|
|
WebApiManager = require "./WebApiManager"
|
|
logger = require "logger-sharelatex"
|
|
|
|
module.exports = UpdateTrimmer =
|
|
shouldTrimUpdates: (project_id, callback = (error, shouldTrim) ->) ->
|
|
MongoManager.getProjectMetaData project_id, (error, metadata) ->
|
|
return callback(error) if error?
|
|
if metadata?.preserveHistory
|
|
return callback null, false
|
|
else
|
|
WebApiManager.getProjectDetails project_id, (error, details) ->
|
|
return callback(error) if error?
|
|
logger.log project_id: project_id, details: details, "got details"
|
|
if details?.features?.versioning
|
|
MongoManager.setProjectMetaData project_id, preserveHistory: true, (error) ->
|
|
return callback(error) if error?
|
|
MongoManager.upgradeHistory project_id, (error) ->
|
|
return callback(error) if error?
|
|
callback null, false
|
|
else
|
|
callback null, true
|
|
|