@@ -515,23 +515,13 @@ def _read_integrity(self, transaction_id, key):
515515 return
516516 return integrity [key ]
517517
518- def open_index (self , transaction_id , auto_recover = True ):
518+ def open_index (self , transaction_id ):
519519 if transaction_id is None :
520520 return NSIndex1 ()
521521 index_path = os .path .join (self .path , "index.%d" % transaction_id )
522522 integrity_data = self ._read_integrity (transaction_id , "index" )
523- try :
524- with IntegrityCheckedFile (index_path , write = False , integrity_data = integrity_data ) as fd :
525- return NSIndex1 .read (fd )
526- except (ValueError , OSError , FileIntegrityError ) as exc :
527- logger .warning ("Repository index missing or corrupted, trying to recover from: %s" , exc )
528- os .unlink (index_path )
529- if not auto_recover :
530- raise
531- self .prepare_txn (self .get_transaction_id ())
532- # don't leave an open transaction around
533- self .commit (compact = False )
534- return self .open_index (self .get_transaction_id ())
523+ with IntegrityCheckedFile (index_path , write = False , integrity_data = integrity_data ) as fd :
524+ return NSIndex1 .read (fd )
535525
536526 def _unpack_hints (self , transaction_id ):
537527 hints_path = os .path .join (self .path , "hints.%d" % transaction_id )
@@ -560,11 +550,11 @@ def prepare_txn(self, transaction_id, do_cleanup=True):
560550 raise
561551 if not self .index or transaction_id is None :
562552 try :
563- self .index = self .open_index (transaction_id , auto_recover = False )
553+ self .index = self .open_index (transaction_id )
564554 except (ValueError , OSError , FileIntegrityError ) as exc :
565555 logger .warning ("Checking repository transaction due to previous error: %s" , exc )
566556 self .check_transaction ()
567- self .index = self .open_index (transaction_id , auto_recover = False )
557+ self .index = self .open_index (transaction_id )
568558 if transaction_id is None :
569559 self .segments = {} # XXX bad name: usage_count_of_segment_x = self.segments[x]
570560 self .compact = FreeSpace () # XXX bad name: freeable_space_of_segment_x = self.compact[x]
0 commit comments