mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
CBR Input: Fix comics with extremely long filenames not working on Windows. Fixes #2031047 [Private bug](https://bugs.launchpad.net/calibre/+bug/2031047)
This commit is contained in:
parent
f916d19522
commit
a940bb92f6
@ -115,7 +115,8 @@ class PageProcessor(list): # {{{
|
||||
from qt.core import QImage
|
||||
|
||||
from calibre.utils.img import crop_image, image_from_data, scale_image
|
||||
with open(self.path_to_page, 'rb') as f:
|
||||
from calibre.utils.filenames import make_long_path_useable
|
||||
with open(make_long_path_useable(self.path_to_page), 'rb') as f:
|
||||
img = image_from_data(f.read())
|
||||
width, height = img.width(), img.height()
|
||||
if self.num == 0: # First image so create a thumbnail from it
|
||||
|
@ -601,8 +601,8 @@ rmtree = shutil.rmtree
|
||||
if iswindows:
|
||||
long_path_prefix = '\\\\?\\'
|
||||
|
||||
def make_long_path_useable(path):
|
||||
if len(path) > 200 and os.path.isabs(path) and not path.startswith(long_path_prefix):
|
||||
def make_long_path_useable(path, threshold=200):
|
||||
if len(path) > threshold and os.path.isabs(path) and not path.startswith(long_path_prefix):
|
||||
path = long_path_prefix + os.path.normpath(path)
|
||||
return path
|
||||
|
||||
@ -636,7 +636,7 @@ if iswindows:
|
||||
raise
|
||||
|
||||
else:
|
||||
def make_long_path_useable(path):
|
||||
def make_long_path_useable(path, threshold=200):
|
||||
return path
|
||||
|
||||
def get_long_path_name(path):
|
||||
|
@ -12,6 +12,7 @@ from io import BytesIO
|
||||
|
||||
from calibre.constants import filesystem_encoding, iswindows
|
||||
from calibre.ptempfile import PersistentTemporaryFile, TemporaryDirectory
|
||||
from calibre.utils.filenames import make_long_path_useable
|
||||
from polyglot.builtins import string_or_bytes
|
||||
|
||||
|
||||
@ -52,19 +53,19 @@ class StreamAsPath:
|
||||
def extract(path_or_stream, location):
|
||||
from unrardll import extract
|
||||
with StreamAsPath(path_or_stream) as path:
|
||||
return extract(path, location)
|
||||
return extract(make_long_path_useable(path), make_long_path_useable(location, threshold=0))
|
||||
|
||||
|
||||
def names(path_or_stream):
|
||||
from unrardll import names
|
||||
with StreamAsPath(path_or_stream) as path:
|
||||
yield from names(path, only_useful=True)
|
||||
yield from names(make_long_path_useable(path), only_useful=True)
|
||||
|
||||
|
||||
def headers(path_or_stream):
|
||||
from unrardll import headers, is_useful
|
||||
with StreamAsPath(path_or_stream) as path:
|
||||
for h in headers(path):
|
||||
for h in headers(make_long_path_useable(path)):
|
||||
if is_useful(h):
|
||||
yield h
|
||||
|
||||
@ -72,7 +73,7 @@ def headers(path_or_stream):
|
||||
def comment(path_or_stream):
|
||||
from unrardll import comment
|
||||
with StreamAsPath(path_or_stream) as path:
|
||||
return comment(path)
|
||||
return comment(make_long_path_useable(path))
|
||||
|
||||
|
||||
def extract_member(
|
||||
@ -89,7 +90,7 @@ def extract_member(
|
||||
(match is not None and match.search(fname) is not None)
|
||||
|
||||
with StreamAsPath(path_or_stream) as path:
|
||||
name, data = extract_member(path, is_match)
|
||||
name, data = extract_member(make_long_path_useable(path), is_match)
|
||||
if name is not None:
|
||||
return name, data
|
||||
|
||||
@ -97,7 +98,7 @@ def extract_member(
|
||||
def extract_members(path_or_stream, callback):
|
||||
from unrardll import extract_members
|
||||
with StreamAsPath(path_or_stream) as path:
|
||||
extract_members(path, callback)
|
||||
extract_members(make_long_path_useable(path), callback)
|
||||
|
||||
|
||||
def extract_first_alphabetically(stream):
|
||||
|
Loading…
x
Reference in New Issue
Block a user