From af95b7c996e20665373708a549729c7377fd5e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Sun, 19 Jun 2011 20:34:46 +0200 Subject: [PATCH] Store stat data even for hard links to make file listing prettier --- darc/archive.py | 5 +++-- darc/archiver.py | 13 +++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/darc/archive.py b/darc/archive.py index 3f658599d..40fa35541 100644 --- a/darc/archive.py +++ b/darc/archive.py @@ -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 diff --git a/darc/archiver.py b/darc/archiver.py index 3f7dbf016..b11e459d3 100644 --- a/darc/archiver.py +++ b/darc/archiver.py @@ -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'))