From 756e2307ecb067bb71d0edb512699d429226e745 Mon Sep 17 00:00:00 2001 From: Terry Geng Date: Fri, 28 Feb 2020 19:58:11 +0800 Subject: [PATCH] fix: delete file if size is 0 #80 --- mumbleBot.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mumbleBot.py b/mumbleBot.py index e720e7a..b6f65ae 100644 --- a/mumbleBot.py +++ b/mumbleBot.py @@ -462,10 +462,13 @@ class MumbleBot: self.log.info("bot: download attempts %d / %d" % (i+1, attempts)) try: ydl.extract_info(url) - if os.path.exists(mp3) and os.stat(mp3).st_size > 0: - music['ready'] = "yes" - download_succeed = True - break + if os.path.exists(mp3): + if os.stat(mp3).st_size > 0: + music['ready'] = "yes" + download_succeed = True + break + else: + os.remove(mp3) else: self.log.error("bot: download failed: file not existed or file size is 0.") except: