From 7bca2bc90c31c9034b5fbeb60bb96dd04548f8f5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 31 Dec 2010 16:28:16 -0700 Subject: [PATCH] Fix #8050 (Error converting CBZ files with Japanese filenames to EPUB) --- src/calibre/utils/zipfile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/utils/zipfile.py b/src/calibre/utils/zipfile.py index 5c19444bd6..7f6e97f7d2 100644 --- a/src/calibre/utils/zipfile.py +++ b/src/calibre/utils/zipfile.py @@ -1087,7 +1087,9 @@ class ZipFile: with open(targetpath, 'wb') as target: shutil.copyfileobj(source, target) except: - targetpath = sanitize_file_name(targetpath) + components = list(os.path.split(targetpath)) + components[-1] = sanitize_file_name(components[-1]) + targetpath = os.sep.join(components) with open(targetpath, 'wb') as target: shutil.copyfileobj(source, target) self.extract_mapping[member.filename] = targetpath