From d6105778839cbdae5bfd234d54929b972328a6ee Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Wed, 9 Mar 2022 18:11:20 +0100 Subject: LocalCAS: Set epoch time for every entry ... and refactor static constant to proper format `kFdLess`. --- src/buildtool/execution_api/local/file_storage.hpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/buildtool/execution_api/local/file_storage.hpp') diff --git a/src/buildtool/execution_api/local/file_storage.hpp b/src/buildtool/execution_api/local/file_storage.hpp index ec7714f6..0af749ad 100644 --- a/src/buildtool/execution_api/local/file_storage.hpp +++ b/src/buildtool/execution_api/local/file_storage.hpp @@ -17,8 +17,7 @@ enum class StoreMode { LastWins }; -template +template class FileStorage { public: explicit FileStorage(std::filesystem::path storage_root) noexcept @@ -47,8 +46,8 @@ class FileStorage { } private: + static constexpr bool kFdLess{kType == ObjectType::Executable}; std::filesystem::path const storage_root_{}; - static constexpr bool fd_less_{kType == ObjectType::Executable}; /// \brief Add file to storage from file path via link or copy and rename. /// If a race-condition occurs, the winning thread will be the one @@ -68,7 +67,8 @@ class FileStorage { // Entry does not exist and we are owner of the file (e.g., file // generated in the execution directory). Try to hard link it // directly or check its existence if it was created by now. - return FileSystemManager::CreateFileHardlinkAs( + return FileSystemManager::CreateFileHardlinkAs( path, file_path) or FileSystemManager::IsFile(file_path); }; @@ -124,10 +124,11 @@ class FileStorage { // directory), prefer faster creation of hard links instead of a copy. // Copy executables without opening any writeable file descriptors in // this process to avoid those from being inherited by child processes. - return (is_owner and FileSystemManager::CreateFileHardlinkAs( - other_path, file_path)) or - FileSystemManager::CopyFileAs( - other_path, file_path, fd_less_); + return (is_owner and + FileSystemManager::CreateFileHardlinkAs( + other_path, file_path)) or + FileSystemManager::CopyFileAs( + other_path, file_path, kFdLess); } /// \brief Create file from bytes. @@ -136,8 +137,8 @@ class FileStorage { std::string const& bytes) noexcept -> bool { // Write executables without opening any writeable file descriptors in // this process to avoid those from being inherited by child processes. - return FileSystemManager::WriteFileAs( - bytes, file_path, fd_less_); + return FileSystemManager::WriteFileAs( + bytes, file_path, kFdLess); } /// \brief Stage file from source path to target path. -- cgit v1.2.3