From 349798a9b81fb4f7f8e1e1963ea9039a4a68a471 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sat, 26 Aug 2023 09:53:32 +0800 Subject: [PATCH] Demote errors from utimensat copying directories * lisp/files.el (copy-directory): Wrap set-file-times within with-demoted-errors. * src/fileio.c (Fcopy_file): Adjust commentary. --- lisp/files.el | 6 +++++- src/fileio.c | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index 1803eb9ed9d..a015dd3cf4d 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -6622,7 +6622,11 @@ into NEWNAME instead." (file-attributes directory)))) (follow-flag (unless follow 'nofollow))) (if modes (set-file-modes newname modes follow-flag)) - (if times (set-file-times newname times follow-flag))))))) + (when times + ;; Don't didactically fail if file times can't be set, as + ;; some file systems forbid modifying them. + (with-demoted-errors "Setting file times: %s" + (set-file-times newname times follow-flag)))))))) ;; At time of writing, only info uses this. diff --git a/src/fileio.c b/src/fileio.c index 51e3e8849d1..23e1a83d8bf 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2518,8 +2518,8 @@ permissions. */) ts[1] = get_stat_mtime (&st); if (futimens (ofd, ts) != 0 /* Various versions of the Android C library are missing - futimens, which leads a gnulib fallback to be installed - that uses fdutimens instead. However, fdutimens is not + futimens, prompting Gnulib to install a fallback that + uses fdutimens instead. However, fdutimens is not supported on many Android kernels, so just silently fail if errno is ENOTSUP or ENOSYS. */ #if defined HAVE_ANDROID && !defined ANDROID_STUBIFY -- 2.39.5