Explorar el Código

check: fix uninitialised variable if repo is completely empty, fixes #7034

Thomas Waldmann hace 2 años
padre
commit
4f4be2631a
Se han modificado 1 ficheros con 1 adiciones y 0 borrados
  1. 1 0
      src/borg/repository.py

+ 1 - 0
src/borg/repository.py

@@ -1027,6 +1027,7 @@ class Repository:
         t_start = time.monotonic()
         t_start = time.monotonic()
         pi = ProgressIndicatorPercent(total=segment_count, msg='Checking segments %3.1f%%', step=0.1,
         pi = ProgressIndicatorPercent(total=segment_count, msg='Checking segments %3.1f%%', step=0.1,
                                       msgid='repository.check')
                                       msgid='repository.check')
+        segment = -1  # avoid uninitialized variable if there are no segment files at all
         for i, (segment, filename) in enumerate(self.io.segment_iterator()):
         for i, (segment, filename) in enumerate(self.io.segment_iterator()):
             pi.show(i)
             pi.show(i)
             if segment <= last_segment_checked:
             if segment <= last_segment_checked: