From 9b7f70b5183f1e0680b3dc61d16906bcad236f4e Mon Sep 17 00:00:00 2001 From: toonn Date: Sat, 21 Dec 2019 17:22:26 +0100 Subject: Restore access to a preview cache in clean mode `--clean` is incredibly useful when testing contributions to `scope.sh` among other things but some (most?) previews require the cache to function. As a compromise every invocation using `--clean` will create a temporary cache directory. Fixes #1783 --- ranger/core/actions.py | 4 ---- ranger/core/main.py | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 18302431..cd6c6afe 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1118,10 +1118,6 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m data['loading'] = False return path - if ranger.args.clean: - # Don't access args.cachedir in clean mode - return None - if not os.path.exists(ranger.args.cachedir): os.makedirs(ranger.args.cachedir) cacheimg = os.path.join(ranger.args.cachedir, self.sha1_encode(path)) diff --git a/ranger/core/main.py b/ranger/core/main.py index aefaacbc..7322a501 100644 --- a/ranger/core/main.py +++ b/ranger/core/main.py @@ -333,7 +333,8 @@ def parse_arguments(): return path if args.clean: - args.cachedir = None + from tempfile import mkdtemp + args.cachedir = mkdtemp(suffix='.ranger-cache') args.confdir = None args.datadir = None else: -- cgit 1.4.1-2-gfad0