mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-24 10:37:23 +00:00
No autoflush on metadata.db change
This commit is contained in:
parent
4a9b01e93b
commit
6f9e52792a
16
cps/db.py
16
cps/db.py
@ -402,7 +402,10 @@ class AlchemyEncoder(json.JSONEncoder):
|
||||
el.append(ele.get())
|
||||
else:
|
||||
el.append(json.dumps(ele, cls=AlchemyEncoder))
|
||||
data = ",".join(el)
|
||||
if field == 'authors':
|
||||
data = " & ".join(el)
|
||||
else:
|
||||
data = ",".join(el)
|
||||
if data == '[]':
|
||||
data = ""
|
||||
else:
|
||||
@ -542,7 +545,7 @@ class CalibreDB():
|
||||
backref='books'))
|
||||
|
||||
cls.session_factory = scoped_session(sessionmaker(autocommit=False,
|
||||
autoflush=True,
|
||||
autoflush=False,
|
||||
bind=cls.engine))
|
||||
for inst in cls.instances:
|
||||
inst.initSession()
|
||||
@ -619,9 +622,12 @@ class CalibreDB():
|
||||
.join(*join, isouter=True) \
|
||||
.filter(db_filter) \
|
||||
.filter(self.common_filters(allow_show_archived))
|
||||
pagination = Pagination(page, pagesize,
|
||||
len(query.all()))
|
||||
entries = query.order_by(*order).offset(off).limit(pagesize).all()
|
||||
try:
|
||||
pagination = Pagination(page, pagesize,
|
||||
len(query.all()))
|
||||
entries = query.order_by(*order).offset(off).limit(pagesize).all()
|
||||
except Exception as e:
|
||||
logger.debug(e)
|
||||
for book in entries:
|
||||
book = self.order_authors(book)
|
||||
return entries, randm, pagination
|
||||
|
@ -394,7 +394,8 @@ def uploadFileToEbooksFolder(destFile, f):
|
||||
if len(existingFiles) > 0:
|
||||
driveFile = existingFiles[0]
|
||||
else:
|
||||
driveFile = drive.CreateFile({'title': x, 'parents': [{"kind": "drive#fileLink", 'id': parent['id']}],})
|
||||
driveFile = drive.CreateFile({'title': x,
|
||||
'parents': [{"kind": "drive#fileLink", 'id': parent['id']}], })
|
||||
driveFile.SetContentFile(f)
|
||||
driveFile.Upload()
|
||||
else:
|
||||
|
@ -123,6 +123,7 @@ class TaskConvert(CalibreTask):
|
||||
book=book_id, uncompressed_size=os.path.getsize(file_path + format_new_ext))
|
||||
try:
|
||||
local_db.session.merge(new_format)
|
||||
local_db.session.flush()
|
||||
local_db.session.commit()
|
||||
except SQLAlchemyError as e:
|
||||
local_db.session.rollback()
|
||||
|
Loading…
Reference in New Issue
Block a user