From cf07fdd6f6d2c8e0de34ec8f95093297c881b281 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Thu, 16 May 2019 11:58:20 -0700 Subject: [PATCH] Request cloning using COPYFILE_CLONE --- tools/common/file_system.cc | 3 ++- tools/worker/work_processor.cc | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/common/file_system.cc b/tools/common/file_system.cc index 2302ad562..79d63f04c 100644 --- a/tools/common/file_system.cc +++ b/tools/common/file_system.cc @@ -33,7 +33,8 @@ bool CopyFile(const std::string &src, const std::string &dest) { #ifdef __APPLE__ // The `copyfile` function with `COPYFILE_ALL` mode preserves permissions and // modification time. - return copyfile(src.c_str(), dest.c_str(), nullptr, COPYFILE_ALL) == 0; + return copyfile(src.c_str(), dest.c_str(), nullptr, + COPYFILE_ALL | COPYFILE_CLONE) == 0; #elif __unix__ // On Linux, we can use `sendfile` to copy it more easily than calling // `read`/`write` in a loop. diff --git a/tools/worker/work_processor.cc b/tools/worker/work_processor.cc index f830bb68d..1a22ee035 100644 --- a/tools/worker/work_processor.cc +++ b/tools/worker/work_processor.cc @@ -160,8 +160,6 @@ void WorkProcessor::ProcessWorkRequest( if (!is_wmo) { // Copy the output files from the incremental storage area back to the // locations where Bazel declared the files. - // TODO(allevato): Investigate copy-on-write on macOS, or hard-linking in - // general, as a possible optimization. for (auto expected_object_pair : output_file_map.incremental_outputs()) { if (!CopyFile(expected_object_pair.second, expected_object_pair.first)) { std::cerr << "Could not copy " << expected_object_pair.second << " to "