浏览代码

Create ~/.darc/ directory if missing

Jonas Borgström 14 年之前
父节点
当前提交
366d4ac8c1
共有 2 个文件被更改,包括 4 次插入1 次删除
  1. 3 0
      darc/archiver.py
  2. 1 1
      darc/cache.py

+ 3 - 0
darc/archiver.py

@@ -196,6 +196,9 @@ class Archiver(object):
         return Keychain(args.keychain).chpass()
         return Keychain(args.keychain).chpass()
 
 
     def run(self, args=None):
     def run(self, args=None):
+        dot_path = os.path.join(os.path.expanduser('~'), '.darc')
+        if not os.path.exists(dot_path):
+            os.mkdir(dot_path)
         default_keychain = os.path.join(os.path.expanduser('~'),
         default_keychain = os.path.join(os.path.expanduser('~'),
                                         '.darc', 'keychain')
                                         '.darc', 'keychain')
         parser = argparse.ArgumentParser(description='DARC - Deduplicating Archiver')
         parser = argparse.ArgumentParser(description='DARC - Deduplicating Archiver')

+ 1 - 1
darc/cache.py

@@ -32,7 +32,7 @@ class Cache(object):
     def create(self):
     def create(self):
         """Create a new empty store at `path`
         """Create a new empty store at `path`
         """
         """
-        os.mkdir(self.path)
+        os.makedirs(self.path)
         with open(os.path.join(self.path, 'README'), 'wb') as fd:
         with open(os.path.join(self.path, 'README'), 'wb') as fd:
             fd.write('This is a DARC cache')
             fd.write('This is a DARC cache')
         config = RawConfigParser()
         config = RawConfigParser()