diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/file_system/TARGETS | 3 | ||||
-rw-r--r-- | src/buildtool/file_system/file_root.hpp | 39 |
2 files changed, 33 insertions, 9 deletions
diff --git a/src/buildtool/file_system/TARGETS b/src/buildtool/file_system/TARGETS index aeefb7f7..b0c0acbd 100644 --- a/src/buildtool/file_system/TARGETS +++ b/src/buildtool/file_system/TARGETS @@ -168,7 +168,10 @@ , "deps": [ "git_tree" , "file_system_manager" + , ["src/buildtool/common", "common"] , ["src/buildtool/common", "artifact_description"] + , ["src/buildtool/common", "artifact_digest_factory"] + , ["src/buildtool/crypto", "hash_function"] , ["src/buildtool/compatibility", "compatibility"] , ["src/buildtool/logging", "log_level"] , ["src/buildtool/logging", "logging"] diff --git a/src/buildtool/file_system/file_root.hpp b/src/buildtool/file_system/file_root.hpp index 8b85f5a9..d7f0c000 100644 --- a/src/buildtool/file_system/file_root.hpp +++ b/src/buildtool/file_system/file_root.hpp @@ -26,7 +26,10 @@ #include "gsl/gsl" #include "nlohmann/json.hpp" #include "src/buildtool/common/artifact_description.hpp" +#include "src/buildtool/common/artifact_digest.hpp" +#include "src/buildtool/common/artifact_digest_factory.hpp" #include "src/buildtool/compatibility/compatibility.hpp" +#include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/file_system/file_system_manager.hpp" #include "src/buildtool/file_system/git_tree.hpp" #include "src/buildtool/logging/log_level.hpp" @@ -230,8 +233,16 @@ class FileRoot { if (auto id = data->Hash()) { auto const& size = data->Size(); if (size) { + auto digest = ArtifactDigestFactory::Create( + HashFunction::Type::GitSHA1, + *id, + *size, + /*is_tree=*/true); + if (not digest) { + return std::nullopt; + } return ArtifactDescription::CreateKnown( - ArtifactDigest{*id, *size, /*is_tree=*/true}, + *std::move(digest), ObjectType::Tree, repository); } @@ -575,17 +586,27 @@ class FileRoot { if (Compatibility::IsCompatible()) { auto compatible_hash = Compatibility::RegisterGitEntry( entry->Hash(), *entry->Blob(), repository); + auto digest = ArtifactDigestFactory::Create( + HashFunction::Type::PlainSHA256, + compatible_hash, + *entry->Size(), + /*is_tree=*/false); + if (not digest) { + return std::nullopt; + } return ArtifactDescription::CreateKnown( - ArtifactDigest{compatible_hash, - *entry->Size(), - /*is_tree=*/false}, - entry->Type()); + *std::move(digest), entry->Type()); + } + auto digest = ArtifactDigestFactory::Create( + HashFunction::Type::GitSHA1, + entry->Hash(), + *entry->Size(), + /*is_tree=*/false); + if (not digest) { + return std::nullopt; } return ArtifactDescription::CreateKnown( - ArtifactDigest{ - entry->Hash(), *entry->Size(), /*is_tree=*/false}, - entry->Type(), - repository); + *std::move(digest), entry->Type(), repository); } } return std::nullopt; |