]> arthur.barton.de Git - bup.git/commitdiff
Require utimensat or utimes/lutimes.
authorRob Browning <rlb@defaultvalue.org>
Mon, 16 Dec 2013 02:30:46 +0000 (20:30 -0600)
committerRob Browning <rlb@defaultvalue.org>
Wed, 18 Dec 2013 22:13:40 +0000 (16:13 -0600)
This was already true (tests would fail), so make it explicit, and if
we do encounter any platforms where none of these functions are
available, we can worry about it then.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/_helpers.c
lib/bup/xstat.py

index acf862c36d8e09771441871a3a584478782c24cb..9634b1e6d0643fcec76ab128023c75a5626f0f5b 100644 (file)
@@ -763,6 +763,16 @@ static PyObject *bup_set_linux_file_attr(PyObject *self, PyObject *args)
 #endif /* def BUP_HAVE_FILE_ATTRS */
 
 
+#ifndef HAVE_UTIMENSAT
+#ifndef HAVE_UTIMES
+#error "cannot find utimensat or utimes()"
+#endif
+#ifndef HAVE_LUTIMES
+#error "cannot find utimensat or lutimes()"
+#endif
+#endif
+
+
 #if defined(HAVE_UTIMENSAT) || defined(HAVE_FUTIMES) || defined(HAVE_LUTIMES)
 
 static int bup_parse_xutime_args(char **path,
index e981f9c14696ac75ad748d0ca2585d8ebfa383c9..54dfbae4a4a5001e6fafb26ee4100c69d1f04f44 100644 (file)
@@ -4,17 +4,6 @@ import stat as pystat
 from bup import _helpers
 
 
-try:
-    _have_bup_utime_ns = _helpers.bup_utime_ns
-except AttributeError, e:
-    _have_bup_utime_ns = False
-
-try:
-    _have_bup_lutime_ns = _helpers.bup_lutime_ns
-except AttributeError, e:
-    _have_bup_lutime_ns = False
-
-
 def timespec_to_nsecs((ts_s, ts_ns)):
     # c.f. _helpers.c: timespec_vals_to_py_ns()
     if ts_ns < 0 or ts_ns > 999999999:
@@ -48,28 +37,18 @@ def fstime_to_sec_str(fstime):
         return '%d.%09d' % (s, ns)
 
 
-if _have_bup_utime_ns:
-    def utime(path, times):
-        """Times must be provided as (atime_ns, mtime_ns)."""
-        atime = nsecs_to_timespec(times[0])
-        mtime = nsecs_to_timespec(times[1])
-        _helpers.bup_utime_ns(path, (atime, mtime))
-else:
-    def utime(path, times):
-        """Times must be provided as (atime_ns, mtime_ns)."""
-        atime = fstime_floor_secs(times[0])
-        mtime = fstime_floor_secs(times[1])
-        os.utime(path, (atime, mtime))
-
-
-if _have_bup_lutime_ns:
-    def lutime(path, times):
-        """Times must be provided as (atime_ns, mtime_ns)."""
-        atime = nsecs_to_timespec(times[0])
-        mtime = nsecs_to_timespec(times[1])
-        _helpers.bup_lutime_ns(path, (atime, mtime))
-else:
-    lutime = False
+def utime(path, times):
+    """Times must be provided as (atime_ns, mtime_ns)."""
+    atime = nsecs_to_timespec(times[0])
+    mtime = nsecs_to_timespec(times[1])
+    _helpers.bup_utime_ns(path, (atime, mtime))
+
+
+def lutime(path, times):
+    """Times must be provided as (atime_ns, mtime_ns)."""
+    atime = nsecs_to_timespec(times[0])
+    mtime = nsecs_to_timespec(times[1])
+    _helpers.bup_lutime_ns(path, (atime, mtime))
 
 
 class stat_result: