diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2025-05-26 13:19:48 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2025-06-04 14:34:44 +0200 |
commit | af8f9a663d69e7bce01be200d556909b90ec1873 (patch) | |
tree | 9b51eb2a757e3c44bb3715013433df580ea2d2f5 /src/buildtool/execution_engine/executor/executor.hpp | |
parent | d1f9bd1744b281adb353226c2f1285508e50ef53 (diff) | |
download | justbuild-af8f9a663d69e7bce01be200d556909b90ec1873.tar.gz |
FileRoot: Ensure all read blobs and trees contain valid entries
In particular, ensure that Git roots check for, e.g., upwards
symlinks, before returning blobs and trees. To ensure that only the
bear minimum extra work is performed for this purpose, Git roots
now keep also the root's GitTreeEntry as a field, allowing the
validity check of root source trees to take place only once and
only if required.
Diffstat (limited to 'src/buildtool/execution_engine/executor/executor.hpp')
-rw-r--r-- | src/buildtool/execution_engine/executor/executor.hpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp index e38a656f..018a1536 100644 --- a/src/buildtool/execution_engine/executor/executor.hpp +++ b/src/buildtool/execution_engine/executor/executor.hpp @@ -457,7 +457,8 @@ class ExecutorImpl { } else { // if known blob is not available, read and upload it - content = ReadGitBlob(repo, repo_config, hash); + content = ReadGitBlob( + repo, repo_config, hash, IsSymlinkObject(info.type)); } if (not content) { logger.Emit(LogLevel::Error, "failed to get content"); @@ -478,15 +479,16 @@ class ExecutorImpl { [[nodiscard]] static auto ReadGitBlob( std::string const& repo, gsl::not_null<const RepositoryConfig*> const& repo_config, - std::string const& hash) noexcept -> std::optional<std::string> { + std::string const& hash, + bool is_symlink) noexcept -> std::optional<std::string> { std::optional<std::string> blob{}; if (auto const* ws_root = repo_config->WorkspaceRoot(repo)) { // try to obtain blob from local workspace's Git CAS, if any - blob = ws_root->ReadBlob(hash); + blob = ws_root->ReadBlob(hash, is_symlink); } if (not blob) { // try to obtain blob from global Git CAS, if any - blob = repo_config->ReadBlobFromGitCAS(hash, /*is_symlink=*/false); + blob = repo_config->ReadBlobFromGitCAS(hash, is_symlink); } return blob; } |