mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-25 01:20:32 +00:00
Remove convert task from db.py - with the fixed from #1565, this no longer seems to be needed
This commit is contained in:
parent
9ce2e8ea53
commit
bf41b04cfa
12
cps/db.py
12
cps/db.py
@ -352,20 +352,8 @@ class CalibreDB(threading.Thread):
|
||||
if i == 'dummy':
|
||||
self.queue.task_done()
|
||||
break
|
||||
if i['task'] == 'add_format':
|
||||
cur_book = self.session.query(Books).filter(Books.id == i['id']).first()
|
||||
cur_book.data.append(i['format'])
|
||||
try:
|
||||
# db.session.merge(cur_book)
|
||||
self.session.commit()
|
||||
except OperationalError as e:
|
||||
self.session.rollback()
|
||||
self.log.error("Database error: %s", e)
|
||||
# self._handleError(_(u"Database error: %(error)s.", error=e))
|
||||
# return
|
||||
self.queue.task_done()
|
||||
|
||||
|
||||
def stop(self):
|
||||
self.queue.put('dummy')
|
||||
|
||||
|
@ -6,6 +6,8 @@ import re
|
||||
from glob import glob
|
||||
from shutil import copyfile
|
||||
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
from cps.services.worker import CalibreTask
|
||||
from cps import calibre_db, db
|
||||
from cps import logger, config
|
||||
@ -84,9 +86,15 @@ class TaskConvert(CalibreTask):
|
||||
book=book_id, uncompressed_size=os.path.getsize(file_path + format_new_ext))
|
||||
|
||||
# todo: this may not be needed anymore, might be able to access the DB directly now. See #1565
|
||||
task = {'task':'add_format','id': book_id, 'format': new_format}
|
||||
self.worker_thread.db_queue.put(task)
|
||||
# To Do how to handle error?
|
||||
cur_book = calibre_db.session.query(db.Books).filter(db.Books.id == book_id).first()
|
||||
cur_book.data.append(new_format)
|
||||
|
||||
try:
|
||||
# db.session.merge(cur_book)
|
||||
calibre_db.session.commit()
|
||||
except SQLAlchemyError as e:
|
||||
calibre_db.session.rollback()
|
||||
log.error("Database error: %s", e)
|
||||
|
||||
'''cur_book.data.append(new_format)
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user