mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Some more long path support in the add code path
This commit is contained in:
parent
2fc2b59331
commit
8fc35d8999
@ -52,6 +52,7 @@ from calibre.ebooks.metadata.opf2 import metadata_to_opf
|
|||||||
from calibre.ptempfile import PersistentTemporaryFile, SpooledTemporaryFile, base_dir
|
from calibre.ptempfile import PersistentTemporaryFile, SpooledTemporaryFile, base_dir
|
||||||
from calibre.utils.config import prefs, tweaks
|
from calibre.utils.config import prefs, tweaks
|
||||||
from calibre.utils.date import UNDEFINED_DATE, now as nowf, utcnow
|
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.icu import lower as icu_lower, sort_key
|
||||||
from calibre.utils.localization import canonicalize_lang
|
from calibre.utils.localization import canonicalize_lang
|
||||||
from polyglot.builtins import cmp, iteritems, itervalues, string_or_bytes
|
from polyglot.builtins import cmp, iteritems, itervalues, string_or_bytes
|
||||||
@ -1950,7 +1951,7 @@ class Cache:
|
|||||||
# message in the GUI during the processing.
|
# message in the GUI during the processing.
|
||||||
npath = run_import_plugins(stream_or_path, fmt)
|
npath = run_import_plugins(stream_or_path, fmt)
|
||||||
fmt = os.path.splitext(npath)[-1].lower().replace('.', '').upper()
|
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
|
needs_close = True
|
||||||
fmt = check_ebook_format(stream_or_path, fmt)
|
fmt = check_ebook_format(stream_or_path, fmt)
|
||||||
|
|
||||||
@ -1972,7 +1973,7 @@ class Cache:
|
|||||||
if hasattr(stream_or_path, 'read'):
|
if hasattr(stream_or_path, 'read'):
|
||||||
stream = stream_or_path
|
stream = stream_or_path
|
||||||
else:
|
else:
|
||||||
stream = open(stream_or_path, 'rb')
|
stream = open(make_long_path_useable(stream_or_path), 'rb')
|
||||||
needs_close = True
|
needs_close = True
|
||||||
try:
|
try:
|
||||||
size, fname = self._do_add_format(book_id, fmt, stream, name)
|
size, fname = self._do_add_format(book_id, fmt, stream, name)
|
||||||
|
@ -242,7 +242,7 @@ class AutoAdder(QObject):
|
|||||||
try:
|
try:
|
||||||
with open(sz, 'rb') as f:
|
with open(sz, 'rb') as f:
|
||||||
sz = int(f.read())
|
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'
|
raise Exception('Looks like the file was written to after'
|
||||||
' we tried to read metadata')
|
' we tried to read metadata')
|
||||||
except:
|
except:
|
||||||
@ -282,7 +282,7 @@ class AutoAdder(QObject):
|
|||||||
duplicates.append(dups)
|
duplicates.append(dups)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.remove(path_to_remove)
|
os.remove(make_long_path_useable(path_to_remove))
|
||||||
self.worker.staging.remove(fname)
|
self.worker.staging.remove(fname)
|
||||||
except:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
|
Loading…
x
Reference in New Issue
Block a user