]> arthur.barton.de Git - bup.git/commitdiff
cmd/xstat: don't report mtime/atime for symlinks if we don't have_ns_timestamps.
authorAvery Pennarun <apenwarr@gmail.com>
Sun, 20 Mar 2011 10:53:42 +0000 (03:53 -0700)
committerAvery Pennarun <apenwarr@gmail.com>
Sun, 20 Mar 2011 10:56:08 +0000 (03:56 -0700)
We can't set the atime/mtime on a symlink anyway if we don't
have_ns_timestamps, which means the values are meaningless.  Report them as
0 in order to avoid triggering a unit test failure.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
cmd/xstat-cmd.py

index 6b371c63aabc2f62a48cfe8d07fb35ba48dcef43..b8e4200204d5b797126216f45d5255286368ee84 100755 (executable)
@@ -6,6 +6,7 @@
 import sys, stat, errno
 from bup import metadata, options, xstat
 from bup.helpers import handle_ctrl_c, saved_errors, add_error, log
+from bup import _helpers
 
 
 def fstimestr(fstime):
@@ -97,9 +98,20 @@ for path in remainder:
     if 'group' in active_fields:
         print 'group:', m.group
     if 'atime' in active_fields:
-        print 'atime: ' + fstimestr(m.atime)
+        # if we don't have_ns_fs_timestamps, that means we have to use
+        # utime(), and utime() has no way to set the mtime/atime of a
+        # symlink.  Thus, the mtime/atime of a symlink is meaningless, so
+        # let's not report it.  (That way scripts comparing before/after
+        # won't trigger.)
+        if _helpers._have_ns_fs_timestamps or not stat.S_ISLNK(m.mode):
+            print 'atime: ' + fstimestr(m.atime)
+        else:
+            print 'atime: 0'
     if 'mtime' in active_fields:
-        print 'mtime: ' + fstimestr(m.mtime)
+        if _helpers._have_ns_fs_timestamps or not stat.S_ISLNK(m.mode):
+            print 'mtime: ' + fstimestr(m.mtime)
+        else:
+            print 'mtime: 0'
     if 'ctime' in active_fields:
         print 'ctime: ' + fstimestr(m.ctime)
     if 'linux-attr' in active_fields and m.linux_attr: