mirror of https://github.com/borgbackup/borg.git
Renamed dedupestore to darc
This commit is contained in:
parent
e405eb4a42
commit
8cdca7aed4
|
@ -97,8 +97,8 @@ class Archiver(object):
|
|||
|
||||
def run(self, args=None):
|
||||
default_keychain = os.path.join(os.path.expanduser('~'),
|
||||
'.dedupestore', 'keychain')
|
||||
parser = argparse.ArgumentParser(description='Dedupestore')
|
||||
'.darc', 'keychain')
|
||||
parser = argparse.ArgumentParser(description='DARC - Deduplicating Archiver')
|
||||
parser.add_argument('-k', '--keychain', dest='keychain', type=str,
|
||||
default=default_keychain,
|
||||
help='Keychain to use')
|
|
@ -13,7 +13,7 @@ class Cache(object):
|
|||
def __init__(self, store, crypto):
|
||||
self.store = store
|
||||
self.crypto = crypto
|
||||
self.path = os.path.join(os.path.expanduser('~'), '.dedupestore', 'cache',
|
||||
self.path = os.path.join(os.path.expanduser('~'), '.darc', 'cache',
|
||||
'%s.cache' % self.store.id.encode('hex'))
|
||||
self.tid = -1
|
||||
self.open()
|
|
@ -17,7 +17,7 @@ from .oaep import OAEP
|
|||
|
||||
|
||||
class KeyChain(object):
|
||||
FILE_ID = 'DDS KEYCHAIN'
|
||||
FILE_ID = 'DARC KEYCHAIN'
|
||||
|
||||
def __init__(self, path=None):
|
||||
self.aes_id = self.rsa_read = self.rsa_create = None
|
|
@ -40,10 +40,10 @@ class Store(object):
|
|||
|
||||
def open(self, path):
|
||||
if not os.path.isdir(path):
|
||||
raise Exception('%s Does not look like a store' % path)
|
||||
db_path = os.path.join(path, 'dedupestore.db')
|
||||
raise Exception('%s Does not look like a darc store' % path)
|
||||
db_path = os.path.join(path, 'darcstore.db')
|
||||
if not os.path.exists(db_path):
|
||||
raise Exception('%s Does not look like a store2')
|
||||
raise Exception('%s Does not look like a darc store')
|
||||
self.lock_fd = open(os.path.join(path, 'lock'), 'w')
|
||||
fcntl.flock(self.lock_fd, fcntl.LOCK_EX)
|
||||
self.path = path
|
||||
|
@ -80,7 +80,7 @@ class Store(object):
|
|||
if not os.path.exists(path):
|
||||
os.mkdir(path)
|
||||
os.mkdir(os.path.join(path, 'bands'))
|
||||
cnx = sqlite3.connect(os.path.join(path, 'dedupestore.db'))
|
||||
cnx = sqlite3.connect(os.path.join(path, 'darcstore.db'))
|
||||
cnx.execute('CREATE TABLE objects(ns BINARY NOT NULL, id BINARY NOT NULL, '
|
||||
'band NOT NULL, offset NOT NULL, size NOT NULL)')
|
||||
cnx.execute('CREATE UNIQUE INDEX objects_pk ON objects(ns, id)')
|
|
@ -15,47 +15,47 @@ class Test(unittest.TestCase):
|
|||
self.store_path = os.path.join(self.tmpdir, 'store')
|
||||
self.keychain = '/tmp/_test_dedupstore.keychain'
|
||||
if not os.path.exists(self.keychain):
|
||||
self.dedupestore('keychain', 'generate')
|
||||
self.dedupestore('init', self.store_path)
|
||||
self.darc('keychain', 'generate')
|
||||
self.darc('init', self.store_path)
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.tmpdir)
|
||||
|
||||
def dedupestore(self, *args, **kwargs):
|
||||
def darc(self, *args, **kwargs):
|
||||
exit_code = kwargs.get('exit_code', 0)
|
||||
args = ['--keychain', self.keychain] + list(args)
|
||||
self.assertEqual(exit_code, self.archiver.run(args))
|
||||
|
||||
def create_src_archive(self, name):
|
||||
src_dir = os.path.join(os.getcwd(), os.path.dirname(__file__))
|
||||
self.dedupestore('create', self.store_path + '::' + name, src_dir)
|
||||
self.darc('create', self.store_path + '::' + name, src_dir)
|
||||
|
||||
def test_basic_functionality(self):
|
||||
self.create_src_archive('test')
|
||||
self.dedupestore('list', self.store_path)
|
||||
self.dedupestore('list', self.store_path + '::test')
|
||||
self.dedupestore('info', self.store_path + '::test')
|
||||
self.dedupestore('verify', self.store_path + '::test')
|
||||
self.darc('list', self.store_path)
|
||||
self.darc('list', self.store_path + '::test')
|
||||
self.darc('info', self.store_path + '::test')
|
||||
self.darc('verify', self.store_path + '::test')
|
||||
dest_dir = os.path.join(self.tmpdir, 'dest')
|
||||
self.dedupestore('extract', self.store_path + '::test', dest_dir)
|
||||
self.dedupestore('delete', self.store_path + '::test')
|
||||
self.darc('extract', self.store_path + '::test', dest_dir)
|
||||
self.darc('delete', self.store_path + '::test')
|
||||
|
||||
def test_corrupted_store(self):
|
||||
self.create_src_archive('test')
|
||||
self.dedupestore('verify', self.store_path + '::test')
|
||||
self.darc('verify', self.store_path + '::test')
|
||||
fd = open(os.path.join(self.tmpdir, 'store', 'bands', '0', '0'), 'r+')
|
||||
fd.seek(1000)
|
||||
fd.write('X')
|
||||
fd.close()
|
||||
self.dedupestore('verify', self.store_path + '::test', exit_code=1)
|
||||
self.darc('verify', self.store_path + '::test', exit_code=1)
|
||||
|
||||
def test_symlinks(self):
|
||||
testdir = os.path.join(self.tmpdir, 'linktest')
|
||||
os.mkdir(testdir)
|
||||
os.symlink('/tmp/somewhere', os.path.join(testdir, 'link'))
|
||||
self.dedupestore('create', self.store_path + '::symlinktest', testdir)
|
||||
self.darc('create', self.store_path + '::symlinktest', testdir)
|
||||
dest_dir = os.path.join(self.tmpdir, 'dest')
|
||||
self.dedupestore('extract', self.store_path + '::symlinktest', dest_dir)
|
||||
self.darc('extract', self.store_path + '::symlinktest', dest_dir)
|
||||
dest = os.path.join(dest_dir, testdir[1:])
|
||||
self.assertEqual(os.path.islink(os.path.join(dest, 'link')), True)
|
||||
self.assertEqual(os.readlink(os.path.join(dest, 'link')), '/tmp/somewhere')
|
|
@ -1,15 +1,21 @@
|
|||
"""
|
||||
Dedupstore
|
||||
==========
|
||||
chunk_cache
|
||||
bandstore
|
||||
dedupestore => dds
|
||||
init command
|
||||
|
||||
|
||||
TODO
|
||||
----
|
||||
* Symbolic links
|
||||
* Owner, group, mode
|
||||
* msgpack
|
||||
* Remote stores
|
||||
* Stat and chunk cache
|
||||
|
||||
DONE
|
||||
----
|
||||
* Encryption
|
||||
* Hard links
|
||||
|
||||
|
||||
* cache redesign
|
||||
* Symbolic links
|
||||
* Owner, group, mode, ctime, mtime
|
||||
|
||||
cache = Cache(path,)
|
||||
|
||||
|
|
9
setup.py
9
setup.py
|
@ -3,15 +3,16 @@
|
|||
|
||||
from setuptools import setup, Extension
|
||||
|
||||
setup(name='Dedupestore',
|
||||
setup(name='darc',
|
||||
version='0.1',
|
||||
author=u'Jonas Borgström',
|
||||
author_email='jonas@borgstrom.se',
|
||||
packages=['dedupestore'],
|
||||
ext_modules=[Extension('dedupestore._speedups', ['dedupestore/_speedups.c'])],
|
||||
packages=['darc'],
|
||||
ext_modules=[Extension('darc._speedups', ['darc/_speedups.c'])],
|
||||
install_requires=['pycrypto', 'msgpack-python', 'pbkdf2.py'],
|
||||
entry_points = {
|
||||
'console_scripts': [
|
||||
'dedupestore = dedupestore.archiver:main',
|
||||
'darc = darc.archiver:main',
|
||||
]
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue