diff --git a/kobo/hub/models.py b/kobo/hub/models.py index da29766f..456b602c 100644 --- a/kobo/hub/models.py +++ b/kobo/hub/models.py @@ -605,10 +605,10 @@ def __str__(self): return u"#%s [method: %s, state: %s, worker: %s, parent: #%s]" % (self.id, self.method, self.get_state_display(), self.worker, self.parent.id) return u"#%s [method: %s, state: %s, worker: %s]" % (self.id, self.method, self.get_state_display(), self.worker) + @transaction.atomic def save(self, *args, **kwargs): - # save to db to precalculate subtask counts and obtain an ID (on insert) for stdout and traceback - super(self.__class__, self).save() - self.subtask_count = self.subtasks().count() + if self.id is not None: + self.subtask_count = self.subtasks().count() super(self.__class__, self).save() self.logs.save() if self.parent: