From 910e8a6cf934b1ec98791555238b1c6ca6344cd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Thu, 17 Oct 2013 09:25:56 +0200 Subject: [PATCH] Added some safeguards against path length limit --- kcc/comic2ebook.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index 71cfc9b..ea84665 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -547,12 +547,16 @@ def genEpubStruct(path): def getWorkFolder(afile): + if len(afile) > 240: + raise UserWarning("Path is too long.") if os.path.isdir(afile): workdir = tempfile.mkdtemp('', 'KCC-TMP-') #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') + if len(fullPath) > 240: + raise UserWarning("Path is too long.") copytree(afile, fullPath) sanitizeTreeBeforeConversion(fullPath) return workdir @@ -579,6 +583,8 @@ def getWorkFolder(afile): else: rmtree(workdir, True) raise TypeError + if len(os.path.join(path, 'OEBPS', 'Images')) > 240: + raise UserWarning("Path is too long.") move(path, path + "_temp") move(path + "_temp", os.path.join(path, 'OEBPS', 'Images')) return path