From 246e3fa00edc995de5edd8e483341b40694fcb02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Sun, 21 Feb 2010 10:59:26 +0100 Subject: [PATCH] Added a uuid base id to repositoty. --- dedupstore/archiver.py | 2 ++ dedupstore/repository.py | 3 +++ 2 files changed, 5 insertions(+) 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())