about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorWojciech Siewierski <wojciech@siewierski.eu>2020-01-27 21:00:14 +0100
committerWojciech Siewierski <wojciech@siewierski.eu>2020-01-27 21:00:14 +0100
commit8af08018f22f0a65ed40c73899a37cfa74b82980 (patch)
tree72e0a41b84e69595c76c071dc5b6825b8e53a86e
parent3965e3eeafac8ce44670cfdc25ccc7b5997a3366 (diff)
downloadranger-8af08018f22f0a65ed40c73899a37cfa74b82980.tar.gz
Cleanup the temporary cache directory in the --clean mode
-rw-r--r--ranger/core/main.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/ranger/core/main.py b/ranger/core/main.py
index 7322a501..16f993cc 100644
--- a/ranger/core/main.py
+++ b/ranger/core/main.py
@@ -6,8 +6,10 @@
 from __future__ import (absolute_import, division, print_function)
 
 from logging import getLogger
+import atexit
 import locale
 import os.path
+import shutil
 import sys
 import tempfile
 
@@ -337,6 +339,17 @@ def parse_arguments():
         args.cachedir = mkdtemp(suffix='.ranger-cache')
         args.confdir = None
         args.datadir = None
+
+        @atexit.register
+        def cleanup_cachedir():  # pylint: disable=unused-variable
+            try:
+                shutil.rmtree(args.cachedir)
+            except Exception as ex:  # pylint: disable=broad-except
+                sys.stderr.write(
+                    "Error during the temporary cache directory cleanup: "
+                    "{}\n".format(ex)
+                )
+
     else:
         args.cachedir = path_init('cachedir')
         args.confdir = path_init('confdir')
ml/tangle.mu.html?h=main&id=4c4d325ca8544f52bb305dbb46b1f8144c33c2af'>4c4d325c ^
a654e4ec ^
a654e4ec ^
3e1349d2 ^
e5c11a51 ^
4690ce81 ^
a654e4ec ^
e5c11a51 ^
3e1349d2 ^
c5ffb6e1 ^

a654e4ec ^



e5c11a51 ^






















a654e4ec ^

c5ffb6e1 ^
e5c11a51 ^
a654e4ec ^
204dae92 ^







97eb971b ^
204dae92 ^


97eb971b ^
204dae92 ^
97eb971b ^
204dae92 ^

97eb971b ^
204dae92 ^





97eb971b ^
204dae92 ^

97eb971b ^
204dae92 ^


97eb971b ^

204dae92 ^



c5ffb6e1 ^


a654e4ec ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99