1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-25 01:06:50 +00:00

Store stat data even for hard links to make file listing prettier

This commit is contained in:
Jonas Borgström 2011-06-19 20:34:46 +02:00
parent fa6a45cb1c
commit af95b7c996
2 changed files with 14 additions and 4 deletions

View file

@ -258,8 +258,9 @@ def process_file(self, path, st, cache):
if st.st_nlink > 1:
source = self.hard_links.get((st.st_ino, st.st_dev))
if (st.st_ino, st.st_dev) in self.hard_links:
self.add_item({'mode': st.st_mode,
'path': path, 'source': source})
item = self.stat_attrs(st, path)
item.update({'path': path, 'source': source})
self.add_item(item)
return
else:
self.hard_links[st.st_ino, st.st_dev] = safe_path

View file

@ -150,8 +150,17 @@ def do_list(self, args):
mode = format_file_mode(item['mode'])
size = item.get('size', 0)
mtime = format_time(datetime.fromtimestamp(item['mtime']))
print '%s%s %-6s %-6s %8d %s %s' % (type, mode, item['user'],
item['group'], size, mtime, item['path'])
if 'source' in item:
if type == 'l':
extra = ' -> %s' % item['source']
else:
type = 'h'
extra = ' link to %s' % item['source']
else:
extra = ''
print '%s%s %-6s %-6s %8d %s %s%s' % (type, mode, item['user'],
item['group'], size, mtime,
item['path'], extra)
else:
for archive in sorted(Archive.list_archives(store, keychain), key=attrgetter('ts')):
print '%-20s %s' % (archive.metadata['name'], to_localtime(archive.ts).strftime('%c'))