X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/7ef4abfc9ef8f8835f83cec90040a8d91a659d00..6d06a771aabaac998b7f15f91603026dc67a352a:/apps/catalogue/tasks.py?ds=inline diff --git a/apps/catalogue/tasks.py b/apps/catalogue/tasks.py index 6d19ee18a..d0437820c 100755 --- a/apps/catalogue/tasks.py +++ b/apps/catalogue/tasks.py @@ -73,7 +73,7 @@ def build_epub(book_id): from catalogue.utils import remove_zip epub = Book.objects.get(pk=book_id).wldocument().as_epub() - # Save the file in new instance. Building MOBI takes time and we don't want + # Save the file in new instance. Building EPUB takes time and we don't want # to overwrite any interim changes. book = Book.objects.get(id=book_id) book.epub_file.save('%s.epub' % book.slug, @@ -101,6 +101,24 @@ def build_mobi(book_id): remove_zip(settings.ALL_MOBI_ZIP) +@task(ignore_result=True, rate_limit=settings.CATALOGUE_MOBI_RATE_LIMIT) +def build_fb2(book_id, *args, **kwargs): + """(Re)builds the MOBI file for a book.""" + from django.core.files import File + from catalogue.models import Book + from catalogue.utils import remove_zip + + fb2 = Book.objects.get(pk=book_id).wldocument().as_fb2() + # Save the file in new instance. Building FB2 takes time and we don't want + # to overwrite any interim changes. + book = Book.objects.get(id=book_id) + book.fb2_file.save('%s.fb2' % book.slug, + File(open(fb2.get_filename()))) + + # remove zip with all mobi files + remove_zip(settings.ALL_FB2_ZIP) + + @task(rate_limit=settings.CATALOGUE_CUSTOMPDF_RATE_LIMIT) def build_custom_pdf(book_id, customizations, file_name): """Builds a custom PDF file."""