concurrency: no model save at file save in tasks
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 5 Aug 2011 14:12:17 +0000 (16:12 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 5 Aug 2011 14:12:17 +0000 (16:12 +0200)
apps/archive/tasks.py

index e257da0..27b6d00 100755 (executable)
@@ -47,10 +47,14 @@ class AudioFormatTask(Task):
 
     @classmethod
     def save(cls, audiobook, file_name):
-        getattr(audiobook, "%s_file" % cls.ext).save(
+        field = "%s_file" % cls.ext
+        getattr(audiobook, field).save(
             "%d.%s" % (audiobook.pk, cls.ext),
-            ExistingFile(file_name)
+            ExistingFile(file_name),
+            save=False
             )
+        Audiobook.objects.filter(pk=audiobook.pk).update(
+            **{field: getattr(audiobook, field)})
 
     @classmethod
     def published(cls, audiobook):