From 30daa23e4204472da7c0637db9638ce78e0016e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Tue, 18 Feb 2014 21:16:36 +0100 Subject: [PATCH] Minor cleanup --- attic/archive.py | 7 ++++--- attic/repository.py | 9 +++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/attic/archive.py b/attic/archive.py index 326240178..d34d256e7 100644 --- a/attic/archive.py +++ b/attic/archive.py @@ -481,9 +481,9 @@ class ArchiveChecker: for id_, (count, size, csize) in self.chunks.iteritems(): if count == 0: unused.add(id_) - unexpected = unused - self.possibly_superseded - if unexpected: - self.report_progress('{} excessive objects found'.format(len(unexpected)), error=True) + orphaned = unused - self.possibly_superseded + if orphaned: + self.report_progress('{} orphaned objects found'.format(len(orphaned)), error=True) if self.repair: for id_ in unused: self.repository.delete(id_) @@ -493,6 +493,7 @@ class ArchiveChecker: def rebuild_chunks(self): # Exclude the manifest from chunks del self.chunks[Manifest.MANIFEST_ID] + def record_unused(id_): if self.chunks.get(id_, (0,))[0] == 0: self.possibly_superseded.add(id_) diff --git a/attic/repository.py b/attic/repository.py index 50dcd5644..28ed09e64 100644 --- a/attic/repository.py +++ b/attic/repository.py @@ -87,7 +87,7 @@ class Repository(object): def get_transaction_id(self): 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: raise self.CheckNeeded(self.path) return index_transaction_id @@ -204,7 +204,7 @@ class Repository(object): assert not self._active_txn report_progress('Starting repository check...') 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: return True if segments_transaction_id is not None: @@ -379,13 +379,10 @@ class LoggedIO(object): for filename in filenames: 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 """ 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): return segment return None