diff --git a/kindlecomicconverter/KCC_gui.py b/kindlecomicconverter/KCC_gui.py index 1f9198a..111df35 100644 --- a/kindlecomicconverter/KCC_gui.py +++ b/kindlecomicconverter/KCC_gui.py @@ -517,7 +517,6 @@ class WorkerThread(QThread): for item in outputPath: GUI.progress.content = '' mobiPath = item.replace('.epub', '.mobi') - os.remove(mobiPath + '_toclean') if GUI.targetDirectory and GUI.targetDirectory != os.path.dirname(mobiPath): try: move(mobiPath, GUI.targetDirectory) @@ -538,8 +537,6 @@ class WorkerThread(QThread): mobiPath = item.replace('.epub', '.mobi') if os.path.exists(mobiPath): os.remove(mobiPath) - if os.path.exists(mobiPath + '_toclean'): - os.remove(mobiPath + '_toclean') MW.addMessage.emit('Failed to process MOBI file!', 'error', False) MW.addTrayMessage.emit('Failed to process MOBI file!', 'Critical') else: diff --git a/kindlecomicconverter/comic2ebook.py b/kindlecomicconverter/comic2ebook.py index 86fcbbc..44746b7 100755 --- a/kindlecomicconverter/comic2ebook.py +++ b/kindlecomicconverter/comic2ebook.py @@ -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)] diff --git a/kindlecomicconverter/dualmetafix.py b/kindlecomicconverter/dualmetafix.py index beddc5a..6a950d8 100644 --- a/kindlecomicconverter/dualmetafix.py +++ b/kindlecomicconverter/dualmetafix.py @@ -136,12 +136,11 @@ def del_exth(rec0, exth_num): class DualMobiMetaFix: - def __init__(self, infile, outfile, asin, is_pdoc): + def __init__(self, outfile, asin, is_pdoc): cdetype = b'EBOK' if is_pdoc: cdetype = b'PDOC' - shutil.copyfile(infile, outfile) f = open(outfile, "r+b") self.datain = mmap.mmap(f.fileno(), 0) self.datain_rec0 = readsection(self.datain, 0)