From 774b5e2149f179d8ae77417e5318530ad218c963 Mon Sep 17 00:00:00 2001 From: Alexandre Beloin Date: Thu, 19 Feb 2015 17:33:01 -0500 Subject: [PATCH] Replace os.rmdir to shutil.rmtree --- sickbeard/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index 946713c0..0283eb5c 100755 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -24,6 +24,7 @@ import socket import os import re import os.path +import shutil from threading import Lock import sys @@ -638,7 +639,6 @@ def initialize(consoleLogging=True): if os.path.exists(restoreDir) and os.path.exists(os.path.join(restoreDir, 'cache')): def restoreCache(srcDir, dstDir): import ntpath - import shutil def path_leaf(path): head, tail = ntpath.split(path) @@ -659,7 +659,10 @@ def initialize(consoleLogging=True): logger.log(u"Restore: restoring cache failed: {0}".format(str(e)), logger.ERROR) finally: if os.path.exists(os.path.join(DATA_DIR, 'restore')): - os.rmdir(os.path.join(DATA_DIR, 'restore')) + try: + shutil.rmtree(os.path.join(DATA_DIR, 'restore')) + except Exception as e: + logger.log(u"Restore: Unable to remove the restore directory: {0}".format(str(e)), logger.ERROR) # clean cache folders if CACHE_DIR: