1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-13 09:46:25 +00:00

Fixed tmp directories

This commit is contained in:
Paweł Jastrzębski
2013-08-12 16:32:40 +02:00
parent b7d7204d40
commit 3d2554c557
2 changed files with 7 additions and 4 deletions

View File

@@ -597,8 +597,8 @@ def genEpubStruct(path):
def getWorkFolder(afile):
if os.path.isdir(afile):
workdir = tempfile.mkdtemp('', 'KCC-TMP-', os.path.join(os.path.splitext(afile)[0], '..'))
if os.path.isdir(afile):
try:
os.rmdir(workdir) # needed for copytree() fails if dst already exists
fullPath = os.path.join(workdir, 'OEBPS', 'Images')
@@ -610,9 +610,12 @@ def getWorkFolder(afile):
raise
elif afile.lower().endswith('.pdf'):
pdf = pdfjpgextract.PdfJpgExtract(afile)
path = pdf.extract()
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:

View File

@@ -70,4 +70,4 @@ class PdfJpgExtract:
njpg += 1
i = iend
return self.path
return self.path, njpg