about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorWojciech Siewierski <wojciech.siewierski@onet.pl>2019-01-09 19:47:01 +0100
committerGitHub <noreply@github.com>2019-01-09 19:47:01 +0100
commitfb1ba4a111f818cf2a7d6e9c2f6be230f60bcf69 (patch)
tree27a6434985dfaa23beb60622ae76d86956fc73b5
parent0d63dea9a7ab249556c832c5c38cd0f62c6b4889 (diff)
parent4995c74baf8986240e1e4fa466800a57a7f82a8e (diff)
downloadranger-fb1ba4a111f818cf2a7d6e9c2f6be230f60bcf69.tar.gz
Merge pull request #1436 from Vifon/imagecachedir
Create the image cache directory only when needed and always if needed
-rw-r--r--ranger/core/actions.py2
-rw-r--r--ranger/core/main.py5
2 files changed, 2 insertions, 5 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 6f4b76d0..92838a21 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -1086,6 +1086,8 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
             data['loading'] = False
             return path
 
+        if not os.path.exists(ranger.args.cachedir):
+            os.makedirs(ranger.args.cachedir)
         cacheimg = os.path.join(ranger.args.cachedir, self.sha1_encode(path))
         if self.settings.preview_images and \
                 os.path.isfile(cacheimg) and \
diff --git a/ranger/core/main.py b/ranger/core/main.py
index 598ce243..17b546c0 100644
--- a/ranger/core/main.py
+++ b/ranger/core/main.py
@@ -145,11 +145,6 @@ def main(
             from ranger.ext import curses_interrupt_handler
             curses_interrupt_handler.install_interrupt_handler()
 
-        # Create cache directory
-        if fm.settings.preview_images and fm.settings.use_preview_script:
-            if not os.path.exists(args.cachedir):
-                os.makedirs(args.cachedir)
-
         if not args.clean:
             # Create data directory
             if not os.path.exists(args.datadir):