浏览代码

When -v is specified with prune, also show the timestamp of each
archive, which is helpful for debugging. Unify this with the
formatting done by "attic list". The spacing is chosen so that
the attic prune output is 79 characters wide when the archive
names are at most 36 characters.

Dan Christensen 11 年之前
父节点
当前提交
78c2ef6a13
共有 2 个文件被更改,包括 9 次插入5 次删除
  1. 5 5
      attic/archiver.py
  2. 4 0
      attic/helpers.py

+ 5 - 5
attic/archiver.py

@@ -14,7 +14,7 @@ from attic.key import key_creator
 from attic.helpers import Error, location_validator, format_time, \
 from attic.helpers import Error, location_validator, format_time, \
     format_file_mode, ExcludePattern, exclude_path, adjust_patterns, to_localtime, \
     format_file_mode, ExcludePattern, exclude_path, adjust_patterns, to_localtime, \
     get_cache_dir, get_keys_dir, format_timedelta, prune_within, prune_split, \
     get_cache_dir, get_keys_dir, format_timedelta, prune_within, prune_split, \
-    Manifest, remove_surrogates, update_excludes
+    Manifest, remove_surrogates, update_excludes, format_archive
 from attic.remote import RepositoryServer, RemoteRepository
 from attic.remote import RepositoryServer, RemoteRepository
 
 
 
 
@@ -277,7 +277,7 @@ Type "Yes I am sure" if you understand this and want to continue.\n""")
                                                   remove_surrogates(item[b'path']), extra))
                                                   remove_surrogates(item[b'path']), extra))
         else:
         else:
             for archive in sorted(Archive.list_archives(repository, key, manifest), key=attrgetter('ts')):
             for archive in sorted(Archive.list_archives(repository, key, manifest), key=attrgetter('ts')):
-                print('%-20s %s' % (archive.metadata[b'name'], to_localtime(archive.ts).strftime('%c')))
+                print(format_archive(archive))
         return self.exit_code
         return self.exit_code
 
 
     def do_info(self, args):
     def do_info(self, args):
@@ -329,12 +329,12 @@ Type "Yes I am sure" if you understand this and want to continue.\n""")
         to_delete = [a for a in archives if a not in keep]
         to_delete = [a for a in archives if a not in keep]
 
 
         for archive in keep:
         for archive in keep:
-            self.print_verbose('Keeping archive "%s"' % archive.name)
+            self.print_verbose('Keeping archive: %s' % format_archive(archive))
         for archive in to_delete:
         for archive in to_delete:
             if args.dry_run:
             if args.dry_run:
-                self.print_verbose('Would prune     "%s"' % archive.name)
+                self.print_verbose('Would prune:     %s' % format_archive(archive))
             else:
             else:
-                self.print_verbose('Pruning archive "%s"' % archive.name)
+                self.print_verbose('Pruning archive: %s' % format_archive(archive))
                 archive.delete(cache)
                 archive.delete(cache)
         return self.exit_code
         return self.exit_code
 
 

+ 4 - 0
attic/helpers.py

@@ -288,6 +288,10 @@ def format_file_size(v):
         return '%d B' % v
         return '%d B' % v
 
 
 
 
+def format_archive(archive):
+    return '%-36s %s' % (archive.name, to_localtime(archive.ts).strftime('%c'))
+
+
 class IntegrityError(Error):
 class IntegrityError(Error):
     """Data integrity error"""
     """Data integrity error"""