diff --git a/dedupstore/archiver.py b/dedupstore/archiver.py index 5f16218c4..a7f5593d0 100644 --- a/dedupstore/archiver.py +++ b/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)) diff --git a/dedupstore/repository.py b/dedupstore/repository.py index 056b799c4..f205afab4 100644 --- a/dedupstore/repository.py +++ b/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())