From 7571f74dbc53e9b4fe3b9000662ca686960db78e Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 23 Sep 2024 12:09:44 +0200 Subject: StorageUtils: Add generation-aware rehashing ID file map Such a file could be used to store mappings of digests from CAS or Git cache to digests of different hash type that represent same content. --- src/buildtool/storage/fs_utils.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/buildtool/storage/fs_utils.hpp') diff --git a/src/buildtool/storage/fs_utils.hpp b/src/buildtool/storage/fs_utils.hpp index 7482457b..25392b91 100644 --- a/src/buildtool/storage/fs_utils.hpp +++ b/src/buildtool/storage/fs_utils.hpp @@ -20,6 +20,7 @@ #include #include "src/buildtool/common/user_structs.hpp" +#include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/file_system/symlinks_map/pragma_special.hpp" #include "src/buildtool/storage/config.hpp" #include "src/buildtool/storage/storage.hpp" @@ -73,6 +74,20 @@ namespace StorageUtils { std::size_t generation = 0) noexcept -> std::filesystem::path; +/// \brief Get the path to the file storing the corresponding artifact hashed by +/// a different hash function. +/// \param storage_config Storage under which the file is to be found. +/// \param target_hash_type Hash type to identify mapping target. +/// \param hash Hash to identify mapping source. +/// \param from_git Flag to distinguish further mapping source (CAS / GitCAS) +/// \param generation Further specificity in location of the file. +[[nodiscard]] auto GetRehashIDFile(StorageConfig const& storage_config, + HashFunction::Type target_hash_type, + std::string const& hash, + bool from_git, + std::size_t generation = 0) noexcept + -> std::filesystem::path; + /// \brief Write a tree id to file. The parent folder of the file must exist! [[nodiscard]] auto WriteTreeIDFile(std::filesystem::path const& tree_id_file, std::string const& tree_id) noexcept -> bool; -- cgit v1.2.3