X-Git-Url: https://git.mdrn.pl/audio.git/blobdiff_plain/42d519535bd4445ef0fa8279876bc6eb9560ad6b..6bd6eda1f20d030e17fdb0e057d64e8fe9a5e36c:/apps/archive/tasks.py?ds=inline diff --git a/apps/archive/tasks.py b/apps/archive/tasks.py index e257da0..37169d2 100755 --- a/apps/archive/tasks.py +++ b/apps/archive/tasks.py @@ -11,6 +11,7 @@ from time import sleep #from celery.decorators import task from celery.task import Task from fabric import api +from fabric.network import disconnect_all from mutagen import File from mutagen import id3 @@ -47,10 +48,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): @@ -79,6 +84,7 @@ class AudioFormatTask(Task): api.sudo(command, user=UPLOAD_SUDO, shell=False) else: api.run(command) + disconnect_all() def run(self, aid): audiobook = Audiobook.objects.get(id=aid)