From a1b874398d33dac04a039d5ca0d770beb1be93c5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 9 Jun 2023 16:01:07 +0530 Subject: [PATCH] CHM Input: Yet another regression opening CHM files with missing internal files on windows. See #2023377 (Since the last update Calibre cannot open some of my ebooks.) [Since the last update Calibre cannot open some of my ebooks.](https://bugs.launchpad.net/calibre/+bug/2023377) --- src/calibre/utils/filenames.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/calibre/utils/filenames.py b/src/calibre/utils/filenames.py index 897b0a47f3..182fab9c1e 100644 --- a/src/calibre/utils/filenames.py +++ b/src/calibre/utils/filenames.py @@ -623,9 +623,13 @@ if iswindows: def get_long_path_name(path): from calibre_extensions.winutil import get_long_path_name - if os.path.isabs(path) and not path.startswith(long_path_prefix): - path = long_path_prefix + path - return get_long_path_name(path) + lpath = path + if os.path.isabs(lpath) and not lpath.startswith(long_path_prefix): + lpath = long_path_prefix + lpath + try: + return get_long_path_name(lpath) + except FileNotFoundError: + return path else: def make_long_path_useable(path):