From f67c6fe8be26326de4fd03d78c15378513999f1d Mon Sep 17 00:00:00 2001 From: Ruud Date: Fri, 20 Sep 2013 16:07:18 +0200 Subject: [PATCH] Only remove images from cache folder on cleanup --- couchpotato/core/plugins/file/main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/couchpotato/core/plugins/file/main.py b/couchpotato/core/plugins/file/main.py index 238bc76c..fc63aca8 100644 --- a/couchpotato/core/plugins/file/main.py +++ b/couchpotato/core/plugins/file/main.py @@ -71,11 +71,11 @@ class FileManager(Plugin): db = get_session() for root, dirs, walk_files in os.walk(Env.get('cache_dir')): for filename in walk_files: - if root == python_cache or 'minified' in root or 'version' in filename or 'temp_updater' in root: continue - file_path = os.path.join(root, filename) - f = db.query(File).filter(File.path == toUnicode(file_path)).first() - if not f: - os.remove(file_path) + if os.path.splitext(filename)[1] in ['.png', '.jpg', '.jpeg']: + file_path = os.path.join(root, filename) + f = db.query(File).filter(File.path == toUnicode(file_path)).first() + if not f: + os.remove(file_path) except: log.error('Failed removing unused file: %s', traceback.format_exc())