diff --git a/src/app/index.coffee b/src/app/index.coffee index 9033213301..7d4fa71daf 100644 --- a/src/app/index.coffee +++ b/src/app/index.coffee @@ -34,8 +34,7 @@ cleanupCorruptTasks = (model) -> user.del("tasks.#{key}") delete tasks[key] - batch = new require('./character').BatchUpdate(model) - batch.startTransaction() + batch = null ## Task List Cleanup _.each ['habit','daily','todo','reward'], (type) -> @@ -51,10 +50,13 @@ cleanupCorruptTasks = (model) -> # There were indeed issues found, set the new list if !_.isEqual(idList, preened) + unless batch? + batch = new require('./character').BatchUpdate(model) + batch.startTransaction() batch.set("#{type}Ids", preened) console.error user.get('id') + "'s #{type}s were corrupt." - batch.commit() + batch.commit() if batch? get '/', (page, model, params, next) -> return page.redirect '/' if page.params?.query?.play?