This commit is contained in:
Kovid Goyal 2025-06-21 07:20:05 +05:30
commit 2e8b8bac6d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -425,7 +425,8 @@ class MTP_DEVICE(BASE):
name = f.name name = f.name
if iswindows: if iswindows:
plen = len(base) plen = len(base)
name = ''.join(shorten_components_to(245-plen, [name])) max_len = 225 if self.is_kindle and path.endswith('.kfx') else 245 # allow for len of additional files
name = ''.join(shorten_components_to(max_len-plen, [name]))
with open(os.path.join(base, name), 'wb') as out: with open(os.path.join(base, name), 'wb') as out:
try: try:
self.get_mtp_file(f, out) self.get_mtp_file(f, out)
@ -436,10 +437,10 @@ class MTP_DEVICE(BASE):
if self.is_kindle and path.endswith('.kfx'): if self.is_kindle and path.endswith('.kfx'):
# copy additional KFX files from the associated .sdr folder # copy additional KFX files from the associated .sdr folder
try: try:
sdr_folder_name = f.name[:-4] + '.sdr' out_folder, out_file = os.path.split(out.name)
new_sdr_path = os.path.join(os.path.split(out.name)[0], sdr_folder_name) new_sdr_path = os.path.join(out_folder, out_file[:-4] + '.sdr')
os.mkdir(new_sdr_path) os.mkdir(new_sdr_path)
self.scan_sdr_for_kfx_files(f.parent, (sdr_folder_name, 'assets'), new_sdr_path) self.scan_sdr_for_kfx_files(f.parent, (f.name[:-4] + '.sdr', 'assets'), new_sdr_path)
except Exception: except Exception:
traceback.print_exc() traceback.print_exc()
return ans return ans