diff --git a/src/calibre/ebooks/oeb/polish/container.py b/src/calibre/ebooks/oeb/polish/container.py index 6db4191e2f..8955d49f0f 100644 --- a/src/calibre/ebooks/oeb/polish/container.py +++ b/src/calibre/ebooks/oeb/polish/container.py @@ -50,7 +50,7 @@ from calibre.ebooks.oeb.polish.parsing import decode_xml from calibre.ebooks.oeb.polish.parsing import parse as parse_html_tweak from calibre.ebooks.oeb.polish.utils import OEB_FONTS, CommentFinder, PositionFinder, adjust_mime_for_epub, guess_type, insert_self_closing, parse_css from calibre.ptempfile import PersistentTemporaryDirectory, PersistentTemporaryFile, TemporaryDirectory -from calibre.utils.filenames import hardlink_file, nlinks_file, retry_on_fail +from calibre.utils.filenames import hardlink_file, make_long_path_useable, nlinks_file, retry_on_fail from calibre.utils.ipc.simple_worker import WorkerError, fork_job from calibre.utils.logging import default_log from calibre.utils.xml_parse import safe_xml_fromstring @@ -1076,7 +1076,7 @@ class Container(ContainerBase): # {{{ this will commit the file if it is dirtied and remove it from the parse cache. You must finish with this file before accessing the parsed version of it again, or bad things will happen. ''' - return open(self.get_file_path_for_processing(name, mode not in {'r', 'rb'}), mode) + return open(make_long_path_useable(self.get_file_path_for_processing(name, mode not in {'r', 'rb'})), mode) def commit(self, outpath=None, keep_parsed=False): ''' diff --git a/src/calibre/ebooks/oeb/polish/kepubify.py b/src/calibre/ebooks/oeb/polish/kepubify.py index 8e201e8227..067c0ca05b 100644 --- a/src/calibre/ebooks/oeb/polish/kepubify.py +++ b/src/calibre/ebooks/oeb/polish/kepubify.py @@ -34,6 +34,7 @@ from calibre.ebooks.oeb.polish.tts import lang_for_elem from calibre.ebooks.oeb.polish.utils import extract, insert_self_closing from calibre.spell.break_iterator import sentence_positions from calibre.srv.render_book import Profiler, calculate_number_of_workers +from calibre.utils.filenames import make_long_path_useable from calibre.utils.localization import canonicalize_lang, get_lang from calibre.utils.short_uuid import uuid4 @@ -371,7 +372,7 @@ def kepubify_html_data(raw: str | bytes, kobo_js_href: str = KOBO_JS_NAME, opts: def kepubify_html_path(path: str, kobo_js_href: str = KOBO_JS_NAME, metadata_lang: str = 'en', opts: Options = Options()): - with open(path, 'r+b') as f: + with open(make_long_path_useable(path), 'r+b') as f: raw = f.read() root = kepubify_html_data(raw, kobo_js_href, opts, metadata_lang) raw = serialize_html(root) @@ -461,7 +462,7 @@ def first_spine_item_is_probably_title_page(container: Container) -> bool: def process_stylesheet_path(path: str, opts: Options) -> None: if opts.needs_stylesheet_processing: - with open(path, 'r+b') as f: + with open(make_long_path_useable(path), 'r+b') as f: css = f.read().decode() ncss = process_stylesheet(css, opts) if ncss is not css: