summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2013-02-16 00:35:07 +0100
committerhut <hut@lavabit.com>2013-02-16 00:35:07 +0100
commit79ac442b161aee65a670fff3cdbf1075a5b3ece9 (patch)
tree6e56ce6ad251df0ab8368b750a7236838d223e94 /ranger
parent311983e6f529c4b18d6e8264a5598591a8c98b37 (diff)
downloadranger-79ac442b161aee65a670fff3cdbf1075a5b3ece9.tar.gz
core.fm: create $confdir when using --copy-config
Diffstat (limited to 'ranger')
-rw-r--r--ranger/core/fm.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/ranger/core/fm.py b/ranger/core/fm.py
index d29e446b..e9ffb888 100644
--- a/ranger/core/fm.py
+++ b/ranger/core/fm.py
@@ -167,12 +167,22 @@ class FM(Actions, SignalDispatcher):
             sys.stderr.write("refusing to copy config files in clean mode\n")
             return
         import shutil
+        from errno import EEXIST
         def copy(_from, to):
             if os.path.exists(self.confpath(to)):
                 sys.stderr.write("already exists: %s\n" % self.confpath(to))
             else:
                 sys.stderr.write("creating: %s\n" % self.confpath(to))
                 try:
+                    os.makedirs(ranger.arg.confdir)
+                except OSError as err:
+                    if err.errno != EEXIST:  # EEXIST means it already exists
+                        print("This configuration directory could not be created:")
+                        print(ranger.arg.confdir)
+                        print("To run ranger without the need for configuration")
+                        print("files, use the --clean option.")
+                        raise SystemExit()
+                try:
                     shutil.copy(self.relpath(_from), self.confpath(to))
                 except Exception as e:
                     sys.stderr.write("  ERROR: %s\n" % str(e))