diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-11-30 12:01:56 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-11-30 14:51:01 +0100 |
commit | e70d12f9e6ec9d384a00c389e2111265fbe54784 (patch) | |
tree | 15f373705efd6e31f1897fe297369d32bf52fdb8 | |
parent | b5d680d0415253d31aa3fe3f6e60e9c777912f6a (diff) | |
download | justbuild-e70d12f9e6ec9d384a00c389e2111265fbe54784.tar.gz |
local API: Implement upload file
... overriding the default implementation. In this way, files can
be added directly to the local CAS without having to completely
reside in memory.
-rw-r--r-- | src/buildtool/execution_api/local/local_api.hpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/buildtool/execution_api/local/local_api.hpp b/src/buildtool/execution_api/local/local_api.hpp index f919e9c9..d46be8ed 100644 --- a/src/buildtool/execution_api/local/local_api.hpp +++ b/src/buildtool/execution_api/local/local_api.hpp @@ -284,6 +284,34 @@ class LocalApi final : public IExecutionApi { return true; } + [[nodiscard]] auto UploadFile(std::filesystem::path const& file_path, + ObjectType type) noexcept -> bool override { + Logger::Log(LogLevel::Trace, [&file_path, &type]() { + return fmt::format("Storing {} of type {} directly to CAS.", + file_path.string(), + ToChar(type)); + }); + switch (type) { + case ObjectType::Tree: + return storage_->CAS() + .StoreTree</* kOwner= */ true>(file_path) + .has_value(); + case ObjectType::Symlink: + case ObjectType::File: + return storage_->CAS() + .StoreBlob</* kOwner= */ true>(file_path, + /* is_executable= */ false) + .has_value(); + case ObjectType::Executable: + return storage_->CAS() + .StoreBlob</* kOwner= */ true>(file_path, + /* is_executable= */ true) + .has_value(); + } + Ensures(false); // unreachable + return false; + } + /// NOLINTNEXTLINE(misc-no-recursion) [[nodiscard]] auto UploadBlobTree(BlobTreePtr const& blob_tree) noexcept -> bool { |