From 658c84d5df6be7710ce76bc9f0b862c6adada726 Mon Sep 17 00:00:00 2001 From: zuckerberg <5-zuckerberg@users.noreply.git.neet.dev> Date: Fri, 24 Sep 2021 16:37:27 -0400 Subject: [PATCH] handle missing directory --- downloader.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/downloader.py b/downloader.py index 1a84573..3740f00 100644 --- a/downloader.py +++ b/downloader.py @@ -99,13 +99,15 @@ def mountTorrent(magnet): o.communicate() # wait for it to finish def umountTorrent(): - o = subprocess.Popen([ - "fusermount", - "-u", fuseTorrentLocation - ]) - o.communicate() # wait for it to finish - os.rmdir(fuseTorrentLocation) - shutil.rmtree(btfsDataLocation) + if os.path.isdir(fuseTorrentLocation): + o = subprocess.Popen([ + "fusermount", + "-u", fuseTorrentLocation + ]) + o.communicate() # wait for it to finish + os.rmdir(fuseTorrentLocation) + if os.path.isdir(btfsDataLocation): + shutil.rmtree(btfsDataLocation) def getTorrentMedia(): files = glob.glob(fuseTorrentLocation + '/**/*', recursive=True)