Browse Source

Merge pull request #977 from ThomasWaldmann/info-show-duration

make borg info more similar to borg create --stats, add duration
TW 9 năm trước cách đây
mục cha
commit
ddc7687d9e
2 tập tin đã thay đổi với 12 bổ sung7 xóa
  1. 4 0
      borg/archive.py
  2. 8 7
      borg/archiver.py

+ 4 - 0
borg/archive.py

@@ -199,6 +199,10 @@ class Archive:
     def duration(self):
         return format_timedelta(self.end - self.start)
 
+    @property
+    def duration_from_meta(self):
+        return format_timedelta(self.ts_end - self.ts)
+
     def __str__(self):
         return '''\
 Archive name: {0.name}

+ 8 - 7
borg/archiver.py

@@ -758,16 +758,17 @@ class Archiver:
             return remove_surrogates(' '.join(shlex.quote(x) for x in cmdline))
 
         stats = archive.calc_stats(cache)
-        print('Name:', archive.name)
-        print('Fingerprint: %s' % archive.fpr)
-        print('Comment:', archive.metadata.get(b'comment', ''))
-        print('Hostname:', archive.metadata[b'hostname'])
-        print('Username:', archive.metadata[b'username'])
+        print('Archive name: %s' % archive.name)
+        print('Archive fingerprint: %s' % archive.fpr)
+        print('Comment: %s' % archive.metadata.get(b'comment', ''))
+        print('Hostname: %s' % archive.metadata[b'hostname'])
+        print('Username: %s' % archive.metadata[b'username'])
         print('Time (start): %s' % format_time(to_localtime(archive.ts)))
         print('Time (end):   %s' % format_time(to_localtime(archive.ts_end)))
-        print('Command line:', format_cmdline(archive.metadata[b'cmdline']))
+        print('Duration: %s' % archive.duration_from_meta)
         print('Number of files: %d' % stats.nfiles)
-        print()
+        print('Command line: %s' % format_cmdline(archive.metadata[b'cmdline']))
+        print(DASHES)
         print(str(stats))
         print(str(cache))
         return self.exit_code