Explorar o código

fix checkpoints when clock jumps

Marian Beermann %!s(int64=8) %!d(string=hai) anos
pai
achega
f5d6093ccc
Modificáronse 1 ficheiros con 3 adicións e 3 borrados
  1. 3 3
      borg/archive.py

+ 3 - 3
borg/archive.py

@@ -215,7 +215,7 @@ class Archive:
             self.chunker = Chunker(self.key.chunk_seed, *chunker_params)
             self.chunker = Chunker(self.key.chunk_seed, *chunker_params)
             if name in manifest.archives:
             if name in manifest.archives:
                 raise self.AlreadyExists(name)
                 raise self.AlreadyExists(name)
-            self.last_checkpoint = time.time()
+            self.last_checkpoint = time.monotonic()
             i = 0
             i = 0
             while True:
             while True:
                 self.checkpoint_name = '%s.checkpoint%s' % (name, i and ('.%d' % i) or '')
                 self.checkpoint_name = '%s.checkpoint%s' % (name, i and ('.%d' % i) or '')
@@ -290,9 +290,9 @@ Number of files: {0.stats.nfiles}'''.format(
         if self.show_progress:
         if self.show_progress:
             self.stats.show_progress(item=item, dt=0.2)
             self.stats.show_progress(item=item, dt=0.2)
         self.items_buffer.add(item)
         self.items_buffer.add(item)
-        if time.time() - self.last_checkpoint > self.checkpoint_interval:
+        if time.monotonic() - self.last_checkpoint > self.checkpoint_interval:
             self.write_checkpoint()
             self.write_checkpoint()
-            self.last_checkpoint = time.time()
+            self.last_checkpoint = time.monotonic()
 
 
     def write_checkpoint(self):
     def write_checkpoint(self):
         self.save(self.checkpoint_name)
         self.save(self.checkpoint_name)