瀏覽代碼

Added a uuid base id to repositoty.

Jonas Borgström 15 年之前
父節點
當前提交
246e3fa00e
共有 2 個文件被更改,包括 5 次插入0 次删除
  1. 2 0
      dedupstore/archiver.py
  2. 3 0
      dedupstore/repository.py

+ 2 - 0
dedupstore/archiver.py

@@ -18,6 +18,8 @@ class Cache(object):
         self.open(path)
 
     def open(self, path):
+        if self.repo.tid == 0:
+            return
         for archive in self.repo.listdir('archives'):
             self.archives.append(archive)
             data = self.repo.get_file(os.path.join('archives', archive))

+ 3 - 0
dedupstore/repository.py

@@ -6,6 +6,7 @@ import os
 import posixpath
 import shutil
 import unittest
+import uuid
 
 log = logging.getLogger('')
 
@@ -30,6 +31,7 @@ class Repository(object):
         log.info('Initializing Repository at "%s"' % path)
         os.mkdir(path)
         open(os.path.join(path, 'VERSION'), 'wb').write(self.VERSION)
+        open(os.path.join(path, 'uuid'), 'wb').write(str(uuid.uuid4()))
         open(os.path.join(path, 'tid'), 'wb').write('0')
         os.mkdir(os.path.join(path, 'data'))
 
@@ -40,6 +42,7 @@ class Repository(object):
         version_path = os.path.join(path, 'version')
         if not os.path.exists(version_path) or open(version_path, 'rb').read() != self.VERSION:
             raise Exception('%s Does not look like a repository2')
+        self.uuid = open(os.path.join(path, 'uuid'), 'rb').read()
         self.lock_fd = open(os.path.join(path, 'lock'), 'w')
         fcntl.flock(self.lock_fd, fcntl.LOCK_EX)
         self.tid = int(open(os.path.join(path, 'tid'), 'r').read())