Replace copyfile + remove with move (#1373)

* remove mobiPath toclean

* remove copyfile _comic.zip
This commit is contained in:
Alex Xu
2026-06-24 18:58:27 -07:00
committed by GitHub
parent 0f009755b1
commit f1b58c83d6
3 changed files with 4 additions and 16 deletions
+3 -11
View File
@@ -34,7 +34,7 @@ from stat import S_IWRITE, S_IREAD, S_IEXEC
from typing import List
from zipfile import ZipFile, ZIP_STORED
from tempfile import mkdtemp, gettempdir
from shutil import move, copytree, rmtree, copyfile
from shutil import move, copytree, rmtree
from multiprocessing import Pool, cpu_count
from uuid import uuid4
from natsort import os_sort_keygen, os_sorted
@@ -1890,12 +1890,7 @@ def makeBook(source, qtgui=None, job_progress=''):
makeZIP(tome + '_comic', tome, job_progress, True)
# Copy files to final destination (PDF files are already saved directly)
if options.format != 'PDF':
copyfile(tome + '_comic.zip', filepath[-1])
try:
os.remove(tome + '_comic.zip')
except FileNotFoundError:
# newly temporary created file is not found. It might have been already deleted
pass
move(tome + '_comic.zip', filepath[-1])
rmtree(tome, True)
if GUI:
GUI.progressBarTick.emit('tick')
@@ -1918,8 +1913,6 @@ def makeBook(source, qtgui=None, job_progress=''):
if not output[0]:
print(f'{job_progress}Error: Failed to tweak KindleGen output!')
return filepath
else:
os.remove(i.replace('.epub', '.mobi') + '_toclean')
if cover and k.path and k.coverSupport:
options.covers[filepath.index(i)][0].saveToKindle(k, options.covers[filepath.index(i)][1])
if options.delete:
@@ -1945,9 +1938,8 @@ def makeMOBIFix(item, uuid):
if not options.keep_epub:
os.remove(item)
mobiPath = item.replace('.epub', '.mobi')
move(mobiPath, mobiPath + '_toclean')
try:
dualmetafix.DualMobiMetaFix(mobiPath + '_toclean', mobiPath, bytes(uuid, 'UTF-8'), is_pdoc)
dualmetafix.DualMobiMetaFix(mobiPath, bytes(uuid, 'UTF-8'), is_pdoc)
return [True]
except Exception as err:
return [False, format(err)]