mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-22 07:43:06 +00:00
Added a uuid base id to repositoty.
This commit is contained in:
parent
21069cc618
commit
246e3fa00e
2 changed files with 5 additions and 0 deletions
|
@ -18,6 +18,8 @@ def __init__(self, path, repo):
|
|||
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))
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
import posixpath
|
||||
import shutil
|
||||
import unittest
|
||||
import uuid
|
||||
|
||||
log = logging.getLogger('')
|
||||
|
||||
|
@ -30,6 +31,7 @@ def create(self, path):
|
|||
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 @@ def open(self, path):
|
|||
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())
|
||||
|
|
Loading…
Reference in a new issue