Skip to content

Commit 62bdbca

Browse files
committed
Fixed a bug that prevented the proper storage of translated ebooks. yihong0618#106
1 parent e4d386a commit 62bdbca

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

advanced.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,8 @@ def done(self, result):
796796
self.status_thread.quit()
797797
self.status_thread.wait()
798798
if self.cache is not None:
799-
self.cache.close()
800-
if not self.cache.is_persistence() and result == 0:
799+
if self.cache.is_persistence():
800+
self.cache.close()
801+
elif result == 0:
801802
self.cache.destroy()
802803
QDialog.done(self, result)

lib/cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def delete(self, ids):
209209
self.connection.commit()
210210

211211
def close(self):
212-
self.cursor.close
212+
self.cursor.close()
213213
self.connection.commit()
214214
self.connection.close()
215215

lib/conversion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def translate_ebook(self, ebook, cache_only=False, is_batch=False):
122122
input_path = ebook.get_input_path()
123123
if not self.config.get('to_library'):
124124
output_path = os.path.join(
125-
self.config.get('output_path'), '%s (%s).%s' % (
125+
self.config.get('output_path'), '%s [%s].%s' % (
126126
ebook.title[:200], ebook.target_lang, ebook.output_format))
127127
else:
128128
output_path = PersistentTemporaryFile(

lib/ebook.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import re
22

3+
from calibre import sanitize_file_name
4+
35

46
class Ebooks:
57
class Ebook:
68
def __init__(self, id, title, files, input_format, source_lang):
79
self.id = id
8-
self.title = title
910
self.files = files
1011
self.input_format = input_format
1112
self.source_lang = source_lang
@@ -14,8 +15,11 @@ def __init__(self, id, title, files, input_format, source_lang):
1415
self.target_lang = None
1516
self.lang_code = None
1617

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

2024
def set_input_format(self, format):
2125
self.input_format = format

0 commit comments

Comments
 (0)