From: Fredrik Tolf Date: Fri, 19 May 2017 15:10:00 +0000 (+0200) Subject: Delete getmanga output files that aren't properly completed. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=daaea5d13e27550f22c603561717d61d7314ede1;p=automanga.git Delete getmanga output files that aren't properly completed. --- diff --git a/getmanga b/getmanga index c744617..7dea808 100755 --- a/getmanga +++ b/getmanga @@ -83,11 +83,17 @@ def download(mng, tdir, pattern): msg(1, "getting %s...", nm) with page.open() as fp: with open(path, "wb") as out: - while True: - data = fp.read(65536) - if data == b"": - break - out.write(data) + done = False + try: + while True: + data = fp.read(65536) + if data == b"": + done = True + break + out.write(data) + finally: + if not done: + os.unlink(path) try: img = Image.open(path) except OSError: