2014-03-28 12:01:34 -04:00
|
|
|
MongoManager = require "./MongoManager"
|
|
|
|
WebApiManager = require "./WebApiManager"
|
|
|
|
logger = require "logger-sharelatex"
|
|
|
|
|
|
|
|
module.exports = UpdateTrimmer =
|
2014-05-16 10:59:12 -04:00
|
|
|
shouldTrimUpdates: (project_id, callback = (error, shouldTrim) ->) ->
|
2014-03-28 12:01:34 -04:00
|
|
|
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?
|
2016-04-07 09:37:53 -04:00
|
|
|
MongoManager.upgradeHistory project_id, (error) ->
|
|
|
|
return callback(error) if error?
|
|
|
|
callback null, false
|
2014-03-28 12:01:34 -04:00
|
|
|
else
|
|
|
|
callback null, true
|
|
|
|
|