summaryrefslogtreecommitdiff
path: root/src/buildtool/storage/fs_utils.cpp
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-03-01 12:02:37 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-03-05 11:05:10 +0100
commitc403ab0da5095d3eb7d139f94a8e9e360e000300 (patch)
treed13b965bfc3283f16d9a2f2758a4cb730d02b5a4 /src/buildtool/storage/fs_utils.cpp
parentd90076c91f7aa83c35a8a0c3840048178dfc1e39 (diff)
downloadjustbuild-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.cpp17
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;