mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 09:46:25 +00:00
Fixed tmp directories
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -70,4 +70,4 @@ class PdfJpgExtract:
|
||||
|
||||
njpg += 1
|
||||
i = iend
|
||||
return self.path
|
||||
return self.path, njpg
|
||||
|
||||
Reference in New Issue
Block a user