Nothing much.

This commit is contained in:
Jonas Borgström 2010-04-18 22:08:12 +02:00
parent eedf969f67
commit 357cad4d5d
4 changed files with 7 additions and 7 deletions

View File

@ -27,7 +27,7 @@ class Archive(object):
self.chunks.append((id, sum, csize, osize))
self.chunk_idx[id] = idx
return idx
def open(self, name):
archive = cPickle.loads(zlib.decompress(self.store.get(NS_ARCHIVES, name)))
self.items = archive['items']
@ -93,9 +93,11 @@ class Archive(object):
for root, dirs, files in os.walk(path):
for d in dirs:
p = os.path.join(root, d)
print p
self.items.append(self.process_dir(p, cache))
for f in files:
p = os.path.join(root, f)
print p
self.items.append(self.process_file(p, cache))
self.save(name)
cache.archives.append(name)
@ -103,13 +105,11 @@ class Archive(object):
def process_dir(self, path, cache):
path = path.lstrip('/\\:')
print 'Directory: %s' % (path)
return {'type': 'DIR', 'path': path}
def process_file(self, path, cache):
with open(path, 'rb') as fd:
path = path.lstrip('/\\:')
print 'Adding: %s...' % path
chunks = []
for chunk in chunkify(fd, CHUNK_SIZE, cache.summap):
chunks.append(self.add_chunk(*cache.add_chunk(chunk)))

View File

@ -58,7 +58,7 @@ class Cache(object):
def save(self):
assert self.store.state == Store.OPEN
print 'saving cache'
data = {'uuid': self.store.uuid,
data = {'uuid': self.store.uuid,
'chunkmap': self.chunkmap, 'summap': self.summap,
'tid': self.store.tid, 'archives': self.archives}
print 'Saving cache as:', self.path
@ -96,7 +96,7 @@ class Cache(object):
def chunk_decref(self, id):
count, sum, csize, osize = self.chunkmap[id]
sumcount = self.summap[sum]
sumcount = self.summap[sum]
if sumcount == 1:
del self.summap[sum]
else:

View File

@ -1,6 +1,6 @@
def checksum(data, sum=0):
"""Simple but fast checksum that can be updated at either end.
>>> checksum('FOOBAR')
102367679
>>> checksum('FOOBAR') == checksum('BAR', checksum('FOO'))

View File

@ -10,4 +10,4 @@ setup(name='Dedupestore',
packages=['dedupestore'],
ext_modules=[Extension('_speedups', ['dedupestore/_speedups.c'])],
)