From 22b744340a94eae7b2f0512bc8fd2b1adadcfd78 Mon Sep 17 00:00:00 2001 From: Ruud Date: Tue, 27 Aug 2013 22:25:56 +0200 Subject: [PATCH] Properly remove backup folder --- couchpotato/runner.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/couchpotato/runner.py b/couchpotato/runner.py index f49ba3e5..2a655d52 100644 --- a/couchpotato/runner.py +++ b/couchpotato/runner.py @@ -102,10 +102,14 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En for backup in backups: if total_backups > 3: if tryInt(os.path.basename(backup)) < time.time() - 259200: - for src_file in src_files: - b_file = toUnicode(os.path.join(backup, os.path.basename(src_file))) - if os.path.isfile(b_file): - os.remove(b_file) + for the_file in os.listdir(backup): + file_path = os.path.join(backup, the_file) + try: + if os.path.isfile(file_path): + os.remove(file_path) + except Exception, e: + raise + os.rmdir(backup) total_backups -= 1