mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-25 01:06:50 +00:00
Minor cleanup
This commit is contained in:
parent
7bcb0f97d6
commit
30daa23e42
2 changed files with 7 additions and 9 deletions
|
@ -481,9 +481,9 @@ def verify_chunks(self):
|
||||||
for id_, (count, size, csize) in self.chunks.iteritems():
|
for id_, (count, size, csize) in self.chunks.iteritems():
|
||||||
if count == 0:
|
if count == 0:
|
||||||
unused.add(id_)
|
unused.add(id_)
|
||||||
unexpected = unused - self.possibly_superseded
|
orphaned = unused - self.possibly_superseded
|
||||||
if unexpected:
|
if orphaned:
|
||||||
self.report_progress('{} excessive objects found'.format(len(unexpected)), error=True)
|
self.report_progress('{} orphaned objects found'.format(len(orphaned)), error=True)
|
||||||
if self.repair:
|
if self.repair:
|
||||||
for id_ in unused:
|
for id_ in unused:
|
||||||
self.repository.delete(id_)
|
self.repository.delete(id_)
|
||||||
|
@ -493,6 +493,7 @@ def verify_chunks(self):
|
||||||
def rebuild_chunks(self):
|
def rebuild_chunks(self):
|
||||||
# Exclude the manifest from chunks
|
# Exclude the manifest from chunks
|
||||||
del self.chunks[Manifest.MANIFEST_ID]
|
del self.chunks[Manifest.MANIFEST_ID]
|
||||||
|
|
||||||
def record_unused(id_):
|
def record_unused(id_):
|
||||||
if self.chunks.get(id_, (0,))[0] == 0:
|
if self.chunks.get(id_, (0,))[0] == 0:
|
||||||
self.possibly_superseded.add(id_)
|
self.possibly_superseded.add(id_)
|
||||||
|
|
|
@ -87,7 +87,7 @@ def get_index_transaction_id(self):
|
||||||
|
|
||||||
def get_transaction_id(self):
|
def get_transaction_id(self):
|
||||||
index_transaction_id = self.get_index_transaction_id()
|
index_transaction_id = self.get_index_transaction_id()
|
||||||
segments_transaction_id = self.io.get_segments_transaction_id(index_transaction_id or 0)
|
segments_transaction_id = self.io.get_segments_transaction_id()
|
||||||
if index_transaction_id != segments_transaction_id:
|
if index_transaction_id != segments_transaction_id:
|
||||||
raise self.CheckNeeded(self.path)
|
raise self.CheckNeeded(self.path)
|
||||||
return index_transaction_id
|
return index_transaction_id
|
||||||
|
@ -204,7 +204,7 @@ def report_progress(msg, error=False):
|
||||||
assert not self._active_txn
|
assert not self._active_txn
|
||||||
report_progress('Starting repository check...')
|
report_progress('Starting repository check...')
|
||||||
index_transaction_id = self.get_index_transaction_id()
|
index_transaction_id = self.get_index_transaction_id()
|
||||||
segments_transaction_id = self.io.get_segments_transaction_id(index_transaction_id)
|
segments_transaction_id = self.io.get_segments_transaction_id()
|
||||||
if index_transaction_id is None and segments_transaction_id is None:
|
if index_transaction_id is None and segments_transaction_id is None:
|
||||||
return True
|
return True
|
||||||
if segments_transaction_id is not None:
|
if segments_transaction_id is not None:
|
||||||
|
@ -379,13 +379,10 @@ def segment_iterator(self, reverse=False):
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
yield int(filename), os.path.join(dirpath, filename)
|
yield int(filename), os.path.join(dirpath, filename)
|
||||||
|
|
||||||
def get_segments_transaction_id(self, index_transaction_id=0):
|
def get_segments_transaction_id(self):
|
||||||
"""Verify that the transaction id is consistent with the index transaction id
|
"""Verify that the transaction id is consistent with the index transaction id
|
||||||
"""
|
"""
|
||||||
for segment, filename in self.segment_iterator(reverse=True):
|
for segment, filename in self.segment_iterator(reverse=True):
|
||||||
# if index_transaction_id is not None and segment < index_transaction_id:
|
|
||||||
# # The index is newer than any committed transaction found
|
|
||||||
# return -1
|
|
||||||
if self.is_committed_segment(filename):
|
if self.is_committed_segment(filename):
|
||||||
return segment
|
return segment
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in a new issue