diff --git a/src/calibre/db/cache.py b/src/calibre/db/cache.py index c4cb1036dd..73a05d493f 100644 --- a/src/calibre/db/cache.py +++ b/src/calibre/db/cache.py @@ -52,6 +52,7 @@ from calibre.ebooks.metadata.opf2 import metadata_to_opf from calibre.ptempfile import PersistentTemporaryFile, SpooledTemporaryFile, base_dir from calibre.utils.config import prefs, tweaks from calibre.utils.date import UNDEFINED_DATE, now as nowf, utcnow +from calibre.utils.filenames import make_long_path_useable from calibre.utils.icu import lower as icu_lower, sort_key from calibre.utils.localization import canonicalize_lang from polyglot.builtins import cmp, iteritems, itervalues, string_or_bytes @@ -1950,7 +1951,7 @@ class Cache: # message in the GUI during the processing. npath = run_import_plugins(stream_or_path, fmt) fmt = os.path.splitext(npath)[-1].lower().replace('.', '').upper() - stream_or_path = open(npath, 'rb') + stream_or_path = open(make_long_path_useable(npath), 'rb') needs_close = True fmt = check_ebook_format(stream_or_path, fmt) @@ -1972,7 +1973,7 @@ class Cache: if hasattr(stream_or_path, 'read'): stream = stream_or_path else: - stream = open(stream_or_path, 'rb') + stream = open(make_long_path_useable(stream_or_path), 'rb') needs_close = True try: size, fname = self._do_add_format(book_id, fmt, stream, name) diff --git a/src/calibre/gui2/auto_add.py b/src/calibre/gui2/auto_add.py index 888045d4a3..e78c9070be 100644 --- a/src/calibre/gui2/auto_add.py +++ b/src/calibre/gui2/auto_add.py @@ -242,7 +242,7 @@ class AutoAdder(QObject): try: with open(sz, 'rb') as f: sz = int(f.read()) - if sz != os.stat(paths[0]).st_size: + if sz != os.stat(make_long_path_useable(paths[0])).st_size: raise Exception('Looks like the file was written to after' ' we tried to read metadata') except: @@ -282,7 +282,7 @@ class AutoAdder(QObject): duplicates.append(dups) try: - os.remove(path_to_remove) + os.remove(make_long_path_useable(path_to_remove)) self.worker.staging.remove(fname) except: import traceback