diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index de71e4b..bb531bb 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -598,8 +598,8 @@ def genEpubStruct(path): def getWorkFolder(afile): - workdir = tempfile.mkdtemp('', 'KCC-TMP-', os.path.join(os.path.splitext(afile)[0], '..')) if os.path.isdir(afile): + workdir = tempfile.mkdtemp('', 'KCC-TMP-', os.path.join(os.path.splitext(afile)[0], '..')) try: os.rmdir(workdir) # needed for copytree() fails if dst already exists fullPath = os.path.join(workdir, 'OEBPS', 'Images') @@ -613,10 +613,10 @@ def getWorkFolder(afile): pdf = pdfjpgextract.PdfJpgExtract(afile) path, njpg = pdf.extract() if njpg == 0: - rmtree(workdir) rmtree(path) raise UserWarning("Failed to extract images.") else: + workdir = tempfile.mkdtemp('', 'KCC-TMP-', os.path.splitext(afile)[0]) cbx = cbxarchive.CBxArchive(afile) if cbx.isCbxFile(): try: