From 47d2e299dba51242db519a6eda60df684f21f3bd Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Thu, 18 Apr 2013 16:32:30 -0400 Subject: [PATCH] only do batch.commit() for corruptedTasks if corruption was found --- src/app/index.coffee | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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?