Jelajahi Sumber

Minor cleanup

Jonas Borgström 11 tahun lalu
induk
melakukan
30daa23e42
2 mengubah file dengan 7 tambahan dan 9 penghapusan
  1. 4 3
      attic/archive.py
  2. 3 6
      attic/repository.py

+ 4 - 3
attic/archive.py

@@ -481,9 +481,9 @@ class ArchiveChecker:
         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
-        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:
         if self.repair:
             for id_ in unused:
             for id_ in unused:
                 self.repository.delete(id_)
                 self.repository.delete(id_)
@@ -493,6 +493,7 @@ class ArchiveChecker:
     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_)

+ 3 - 6
attic/repository.py

@@ -87,7 +87,7 @@ class Repository(object):
 
 
     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 @@ class Repository(object):
         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 @@ class LoggedIO(object):
             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