diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-03-01 12:02:37 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-03-05 11:05:10 +0100 |
commit | c403ab0da5095d3eb7d139f94a8e9e360e000300 (patch) | |
tree | d13b965bfc3283f16d9a2f2758a4cb730d02b5a4 /src/buildtool/storage/fs_utils.cpp | |
parent | d90076c91f7aa83c35a8a0c3840048178dfc1e39 (diff) | |
download | justbuild-c403ab0da5095d3eb7d139f94a8e9e360e000300.tar.gz |
fs_utils: specify path for foreign-file root cache
As the internal distdir data structure now supports the
executable bit, it is also expressive enough to support
foreign-file repositories. Hence we can use this cache,
getting potentially more cache hits.
Diffstat (limited to 'src/buildtool/storage/fs_utils.cpp')
-rw-r--r-- | src/buildtool/storage/fs_utils.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/buildtool/storage/fs_utils.cpp b/src/buildtool/storage/fs_utils.cpp index f6055579..83167181 100644 --- a/src/buildtool/storage/fs_utils.cpp +++ b/src/buildtool/storage/fs_utils.cpp @@ -14,6 +14,10 @@ #include "src/buildtool/storage/fs_utils.hpp" +#include <unordered_map> +#include <utility> + +#include "nlohmann/json.hpp" #include "src/buildtool/file_system/file_system_manager.hpp" #include "src/buildtool/storage/config.hpp" #include "src/buildtool/storage/storage.hpp" @@ -63,6 +67,19 @@ auto GetArchiveTreeIDFile(std::string const& repo_type, return StorageConfig::BuildRoot() / "tree-map" / repo_type / content; } +auto GetForeignFileTreeIDFile(std::string const& content, + std::string const& name, + bool executable) noexcept + -> std::filesystem::path { + return GetDistdirTreeIDFile( + HashFunction::ComputeBlobHash( + nlohmann::json( + std::unordered_map<std::string, std::pair<std::string, bool>>{ + {name, {content, executable}}}) + .dump()) + .HexString()); +} + auto GetDistdirTreeIDFile(std::string const& content) noexcept -> std::filesystem::path { return StorageConfig::BuildRoot() / "distfiles-tree-map" / content; |