mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 12:02:13 +00:00
only do batch.commit() for corruptedTasks if corruption was found
This commit is contained in:
parent
2ea0b1b673
commit
47d2e299db
1 changed files with 5 additions and 3 deletions
|
|
@ -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?
|
||||
|
|
|
|||
Loading…
Reference in a new issue