diff --git a/borg/archive.py b/borg/archive.py index f6acf8be4..ca653ee8e 100644 --- a/borg/archive.py +++ b/borg/archive.py @@ -37,8 +37,6 @@ CHUNKER_PARAMS = (CHUNK_MIN_EXP, CHUNK_MAX_EXP, HASH_MASK_BITS, HASH_WINDOW_SIZE # chunker params for the items metadata stream, finer granularity ITEMS_CHUNKER_PARAMS = (12, 16, 14, HASH_WINDOW_SIZE) -utime_supports_fd = os.utime in getattr(os, 'supports_fd', {}) -utime_supports_follow_symlinks = os.utime in getattr(os, 'supports_follow_symlinks', {}) has_lchmod = hasattr(os, 'lchmod') has_lchflags = hasattr(os, 'lchflags') @@ -385,12 +383,10 @@ Number of files: {0.stats.nfiles}'''.format(self) else: # old archives only had mtime in item metadata atime = mtime - if fd and utime_supports_fd: # Python >= 3.3 + if fd: os.utime(fd, None, ns=(atime, mtime)) - elif utime_supports_follow_symlinks: # Python >= 3.3 + else: os.utime(path, None, ns=(atime, mtime), follow_symlinks=False) - elif not symlink: - os.utime(path, (atime / 1e9, mtime / 1e9)) acl_set(path, item, self.numeric_owner) # Only available on OS X and FreeBSD if has_lchflags and b'bsdflags' in item: diff --git a/borg/testsuite/__init__.py b/borg/testsuite/__init__.py index cb643153b..67c97789b 100644 --- a/borg/testsuite/__init__.py +++ b/borg/testsuite/__init__.py @@ -30,8 +30,6 @@ else: if sys.platform.startswith('netbsd'): st_mtime_ns_round = -4 # only >1 microsecond resolution here? -utime_supports_fd = os.utime in getattr(os, 'supports_fd', {}) - class BaseTestCase(unittest.TestCase): """ @@ -78,14 +76,13 @@ class BaseTestCase(unittest.TestCase): d1[4] = None if not stat.S_ISCHR(d2[1]) and not stat.S_ISBLK(d2[1]): d2[4] = None - if not os.path.islink(path1) or utime_supports_fd: - # Older versions of llfuse do not support ns precision properly - if fuse and not have_fuse_mtime_ns: - d1.append(round(s1.st_mtime_ns, -4)) - d2.append(round(s2.st_mtime_ns, -4)) - else: - d1.append(round(s1.st_mtime_ns, st_mtime_ns_round)) - d2.append(round(s2.st_mtime_ns, st_mtime_ns_round)) + # Older versions of llfuse do not support ns precision properly + if fuse and not have_fuse_mtime_ns: + d1.append(round(s1.st_mtime_ns, -4)) + d2.append(round(s2.st_mtime_ns, -4)) + else: + d1.append(round(s1.st_mtime_ns, st_mtime_ns_round)) + d2.append(round(s2.st_mtime_ns, st_mtime_ns_round)) d1.append(get_all(path1, follow_symlinks=False)) d2.append(get_all(path2, follow_symlinks=False)) self.assert_equal(d1, d2)