summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/__main__.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/ranger/__main__.py b/ranger/__main__.py
index cbb87cc2..3ae71fc0 100644
--- a/ranger/__main__.py
+++ b/ranger/__main__.py
@@ -60,19 +60,27 @@ def parse_arguments():
 	return arg
 
 
-def load_settings(fm, clean):
-	if not clean:
+def allow_access_to_confdir(confdir, allow):
+	if allow:
 		try:
-			os.makedirs(ranger.arg.confdir)
+			os.makedirs(confdir)
 		except OSError as err:
 			if err.errno != 17:  # 17 means it already exists
 				print("This configuration directory could not be created:")
-				print(ranger.arg.confdir)
+				print(confdir)
 				print("To run ranger without the need for configuration")
 				print("files, use the --clean option.")
 				raise SystemExit()
+		if not confdir in sys.path:
+			sys.path[0:0] = [confdir]
+	else:
+		if sys.path[0] == confdir:
+			del sys.path[0]
 
-		sys.path[0:0] = [ranger.arg.confdir]
+
+def load_settings(fm, clean):
+	if not clean:
+		allow_access_to_confdir(ranger.arg.confdir, True)
 
 		# Load commands
 		comcont = ranger.api.commands.CommandContainer()
@@ -107,7 +115,7 @@ def load_settings(fm, clean):
 			print("Warning: the syntax for ~/.ranger/keys.py has changed.")
 			print("Your custom keys are not loaded."\
 					"  Please update your configuration.")
-		del sys.path[0]
+		allow_access_to_confdir(ranger.arg.confdir, False)
 	else:
 		comcont = ranger.api.commands.CommandContainer()
 		ranger.api.commands.alias = comcont.alias
919a680ed907c9a'>5763322b ^
f0cf7af7 ^
5763322b ^
f0cf7af7 ^
b22e5e14 ^
5763322b ^

34514ae8 ^
f898ee7a ^
f0cf7af7 ^


34514ae8 ^

f0cf7af7 ^


c912b731 ^
5763322b ^


f0f16bdf ^
f0cf7af7 ^
5763322b ^
f0cf7af7 ^
53172ce1 ^
34514ae8 ^
f0cf7af7 ^
c912b731 ^
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