From 407cb8df0374511d4146922d7932ddd71066e8da Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 6 Sep 2022 12:58:31 +0200 Subject: Just-MR: Add archive content-in-CAS map Calls libcurl to fetch the archives from the internet. --- src/other_tools/just_mr/utils.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/other_tools/just_mr/utils.cpp') diff --git a/src/other_tools/just_mr/utils.cpp b/src/other_tools/just_mr/utils.cpp index 3470b7db..4d668bc6 100644 --- a/src/other_tools/just_mr/utils.cpp +++ b/src/other_tools/just_mr/utils.cpp @@ -14,6 +14,8 @@ #include "src/other_tools/just_mr/utils.hpp" +#include "src/buildtool/execution_api/local/file_storage.hpp" +#include "src/buildtool/execution_api/local/local_cas.hpp" #include "src/utils/cpp/path.hpp" namespace JustMR::Utils { @@ -74,4 +76,28 @@ auto WriteTreeIDFile(std::filesystem::path const& tree_id_file, return FileSystemManager::Rename(tmp_file.string(), tree_id_file); } +auto AddToCAS(std::string const& data) noexcept + -> std::optional { + // get file CAS instance + auto const& casf = LocalCAS::Instance(); + // write to casf + auto digest = casf.StoreBlobFromBytes(data); + if (digest) { + return casf.BlobPath(*digest); + } + return std::nullopt; +} + +void AddDistfileToCAS(std::filesystem::path const& distfile, + JustMR::PathsPtr const& just_mr_paths) noexcept { + auto const& casf = LocalCAS::Instance(); + for (auto const& dirpath : just_mr_paths->distdirs) { + auto candidate = dirpath / distfile; + if (FileSystemManager::Exists(candidate)) { + // try to add to CAS + [[maybe_unused]] auto digest = casf.StoreBlobFromFile(candidate); + } + } +} + } // namespace JustMR::Utils -- cgit v1.2.3