فهرست منبع

borg create: fix stats

master branch only (not present in 1.1-maint):

stats were computed at 2 different places, but the summing up was missing.
Thomas Waldmann 7 سال پیش
والد
کامیت
427e2ca5fb
2فایلهای تغییر یافته به همراه11 افزوده شده و 0 حذف شده
  1. 10 0
      src/borg/archive.py
  2. 1 0
      src/borg/archiver.py

+ 10 - 0
src/borg/archive.py

@@ -65,6 +65,16 @@ class Statistics:
         if unique:
             self.usize += csize
 
+    def __add__(self, other):
+        if not isinstance(other, Statistics):
+            raise TypeError('can only add Statistics objects')
+        stats = Statistics(self.output_json)
+        stats.osize = self.osize + other.osize
+        stats.csize = self.csize + other.csize
+        stats.usize = self.usize + other.usize
+        stats.nfiles = self.nfiles + other.nfiles
+        return stats
+
     summary = "{label:15} {stats.osize_fmt:>20s} {stats.csize_fmt:>20s} {stats.usize_fmt:>20s}"
 
     def __str__(self):

+ 1 - 0
src/borg/archiver.py

@@ -482,6 +482,7 @@ class Archiver:
                 if args.progress:
                     archive.stats.show_progress(final=True)
                 args.stats |= args.json
+                archive.stats += fso.stats
                 if args.stats:
                     if args.json:
                         json_print(basic_json_data(manifest, cache=cache, extra={