mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-23 00:07:38 +00:00
Various fixes.
This commit is contained in:
parent
aebf3cc6b1
commit
f6473155c9
1 changed files with 22 additions and 14 deletions
|
@ -79,27 +79,35 @@ def add_chunk(self, data):
|
||||||
else:
|
else:
|
||||||
size = 0
|
size = 0
|
||||||
#print 'seen chunk', hash.encode('hex')
|
#print 'seen chunk', hash.encode('hex')
|
||||||
self.chunk_incref(hash)
|
self.chunk_incref(id)
|
||||||
return hash, size
|
return id, size
|
||||||
|
|
||||||
def seen_chunk(self, hash):
|
def seen_chunk(self, hash):
|
||||||
return self.chunkmap.get(hash, 0) > 0
|
return self.chunkmap.get(hash, 0) > 0
|
||||||
|
|
||||||
def chunk_incref(self, hash):
|
def chunk_incref(self, id):
|
||||||
sum = struct.unpack('I', hash[:4])[0]
|
sum = struct.unpack('I', id[:4])[0]
|
||||||
self.chunkmap.setdefault(hash, 0)
|
self.chunkmap.setdefault(id, 0)
|
||||||
self.summap.setdefault(sum, 0)
|
self.summap.setdefault(sum, 0)
|
||||||
self.chunkmap[hash] += 1
|
self.chunkmap[id] += 1
|
||||||
self.summap[sum] += 1
|
self.summap[sum] += 1
|
||||||
|
|
||||||
def chunk_decref(self, hash):
|
def chunk_decref(self, id):
|
||||||
self.summap[struct.unpack('I', hash[:4])[0]] -= 1
|
sum = struct.unpack('I', id[:4])[0]
|
||||||
count = self.chunkmap.get(hash, 0) - 1
|
sumcount = self.summap[sum] - 1
|
||||||
|
count = self.chunkmap[id] - 1
|
||||||
|
assert sumcount >= 0
|
||||||
assert count >= 0
|
assert count >= 0
|
||||||
self.chunkmap[hash] = count
|
if sumcount:
|
||||||
if not count:
|
self.summap[sum] = sumcount
|
||||||
print 'deleting chunk: ', hash.encode('hex')
|
else:
|
||||||
self.store.delete(NS_CHUNKS, hash)
|
del self.summap[sum]
|
||||||
|
if count:
|
||||||
|
self.chunkmap[id] = count
|
||||||
|
else:
|
||||||
|
del self.chunkmap[id]
|
||||||
|
print 'deleting chunk: ', id.encode('hex')
|
||||||
|
self.store.delete(NS_CHUNKS, id)
|
||||||
return count
|
return count
|
||||||
|
|
||||||
|
|
||||||
|
@ -209,7 +217,7 @@ def process_file(self, path, cache):
|
||||||
path = path.lstrip('/\\:')
|
path = path.lstrip('/\\:')
|
||||||
ratio = origsize and compsize * 100 / origsize or 0
|
ratio = origsize and compsize * 100 / origsize or 0
|
||||||
print '(%d chunks: %d%%)' % (len(chunks), ratio)
|
print '(%d chunks: %d%%)' % (len(chunks), ratio)
|
||||||
return {'type': 'FILE', 'path': path, 'size': size, 'chunks': chunks}
|
return {'type': 'FILE', 'path': path, 'size': origsize, 'chunks': chunks}
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
parser = OptionParser()
|
parser = OptionParser()
|
||||||
|
|
Loading…
Reference in a new issue