Skip to content

Commit

Permalink
Fixed a bug that prevented the proper storage of translated ebooks. #106
Browse files Browse the repository at this point in the history
  • Loading branch information
bookfere committed Aug 17, 2023
1 parent e4d386a commit 62bdbca
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,8 @@ def done(self, result):
self.status_thread.quit()
self.status_thread.wait()
if self.cache is not None:
self.cache.close()
if not self.cache.is_persistence() and result == 0:
if self.cache.is_persistence():
self.cache.close()
elif result == 0:
self.cache.destroy()
QDialog.done(self, result)
2 changes: 1 addition & 1 deletion lib/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def delete(self, ids):
self.connection.commit()

def close(self):
self.cursor.close
self.cursor.close()
self.connection.commit()
self.connection.close()

Expand Down
2 changes: 1 addition & 1 deletion lib/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def translate_ebook(self, ebook, cache_only=False, is_batch=False):
input_path = ebook.get_input_path()
if not self.config.get('to_library'):
output_path = os.path.join(
self.config.get('output_path'), '%s (%s).%s' % (
self.config.get('output_path'), '%s [%s].%s' % (
ebook.title[:200], ebook.target_lang, ebook.output_format))
else:
output_path = PersistentTemporaryFile(
Expand Down
8 changes: 6 additions & 2 deletions lib/ebook.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import re

from calibre import sanitize_file_name


class Ebooks:
class Ebook:
def __init__(self, id, title, files, input_format, source_lang):
self.id = id
self.title = title
self.files = files
self.input_format = input_format
self.source_lang = source_lang
Expand All @@ -14,8 +15,11 @@ def __init__(self, id, title, files, input_format, source_lang):
self.target_lang = None
self.lang_code = None

self.set_title(title)

def set_title(self, title):
self.title = re.sub(r'^\.+|[\/\\\\<>:"|?*\n\t]', '', title)
self.title = sanitize_file_name(title)
# self.title = re.sub(r'^\.+|[\/\\\\<>:"|?*\n\t]', '', title)

def set_input_format(self, format):
self.input_format = format
Expand Down

0 comments on commit 62bdbca

Please sign in to comment.