From 5c18d48fda4375878979d54946f1fb4591a0c57b Mon Sep 17 00:00:00 2001 From: KWSys Upstream Date: Thu, 19 Sep 2024 11:34:27 -0400 Subject: [PATCH] KWSys 2024-09-19 (2d72c140) Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit 2d72c140191cfeb1e5bf447683dac2c222603207 (master). Upstream Shortlog ----------------- Mike Lundy (1): ee3223d7 SystemTools: fix clonefile optimization on macOS --- SystemTools.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SystemTools.cxx b/SystemTools.cxx index cc2c7fa300..6cc103df51 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -2597,8 +2597,12 @@ SystemTools::CopyStatus SystemTools::CloneFileContent( // NOTE: we cannot use `clonefile` as the {a,c,m}time for the file needs to // be updated by `copy_file_if_different` and `copy_file`. + // These flags are meant to be COPYFILE_METADATA | COPYFILE_CLONE, but CLONE + // forces COPYFILE_NOFOLLOW_SRC and that violates the invariant that this + // should result in a file. if (copyfile(source.c_str(), destination.c_str(), nullptr, - COPYFILE_METADATA | COPYFILE_CLONE) < 0) { + COPYFILE_METADATA | COPYFILE_EXCL | COPYFILE_STAT | + COPYFILE_XATTR | COPYFILE_DATA) < 0) { return CopyStatus{ Status::POSIX_errno(), CopyStatus::NoPath }; } # if KWSYS_CXX_HAS_UTIMENSAT