mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Address code review comments
This commit is contained in:
parent
a26ba63e1f
commit
1f2b890f10
@ -390,8 +390,9 @@ class FileTypePlugin(Plugin): # {{{
|
|||||||
|
|
||||||
def postconvert(self, book_id, book_format, db):
|
def postconvert(self, book_id, book_format, db):
|
||||||
'''
|
'''
|
||||||
Called post conversion, i.e., after the book file has been added to the database. It is
|
Called post conversion, i.e., after the book file has been added to the database. Note that
|
||||||
useful for modifying the book record based on the contents of the newly added file.
|
it is run after a conversion only, not after a book is added. It is useful for modifying
|
||||||
|
the book record based on the contents of the newly added file.
|
||||||
|
|
||||||
:param book_id: Database id of the added book.
|
:param book_id: Database id of the added book.
|
||||||
:param book_format: The file type of the book that was added.
|
:param book_format: The file type of the book that was added.
|
||||||
@ -401,8 +402,10 @@ class FileTypePlugin(Plugin): # {{{
|
|||||||
|
|
||||||
def postdelete(self, book_id, book_format, db):
|
def postdelete(self, book_id, book_format, db):
|
||||||
'''
|
'''
|
||||||
Called post deletion, i.e., after the book file has been deleted from the database. It is
|
Called post deletion, i.e., after the book file has been deleted from the database. Note
|
||||||
useful for modifying the book record based on the format of the deleted file.
|
that it is not run when a book record is deleted, only when one or more formats from the
|
||||||
|
book are deleted. It is useful for modifying the book record based on the format of the
|
||||||
|
deleted file.
|
||||||
|
|
||||||
:param book_id: Database id of the added book.
|
:param book_id: Database id of the added book.
|
||||||
:param book_format: The file type of the book that was added.
|
:param book_format: The file type of the book that was added.
|
||||||
|
@ -7,7 +7,7 @@ import shutil
|
|||||||
import tempfile
|
import tempfile
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
|
||||||
from calibre.customize.ui import input_profiles, output_profiles
|
from calibre.customize.ui import input_profiles, output_profiles, run_plugins_on_postconvert
|
||||||
from calibre.db.errors import NoSuchBook
|
from calibre.db.errors import NoSuchBook
|
||||||
from calibre.srv.changes import formats_added
|
from calibre.srv.changes import formats_added
|
||||||
from calibre.srv.errors import BookNotFound, HTTPNotFound
|
from calibre.srv.errors import BookNotFound, HTTPNotFound
|
||||||
@ -194,6 +194,7 @@ def conversion_status(ctx, rd, job_id):
|
|||||||
except NoSuchBook:
|
except NoSuchBook:
|
||||||
raise HTTPNotFound(
|
raise HTTPNotFound(
|
||||||
f'book_id {job_status.book_id} not found in library')
|
f'book_id {job_status.book_id} not found in library')
|
||||||
|
run_plugins_on_postconvert(db, job_status.book_id, fmt)
|
||||||
formats_added({job_status.book_id: (fmt,)})
|
formats_added({job_status.book_id: (fmt,)})
|
||||||
ans['size'] = os.path.getsize(job_status.output_path)
|
ans['size'] = os.path.getsize(job_status.output_path)
|
||||||
ans['fmt'] = fmt
|
ans['fmt'] = fmt
|
||||||
|
Loading…
x
Reference in New Issue
Block a user