summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2022-09-12 14:06:45 +0200
committerJoel Rosdahl <joel@rosdahl.net>2022-09-21 17:06:30 +0200
commitd663cb51088f28b921262a54aea6e1f0d809182f (patch)
tree07e475f82df62c4083039c73ad78d4df2fd2ba69 /src/core
parent60fe1672d9e36f4334d39d0c606dd07d401e1fa1 (diff)
downloadccache-d663cb51088f28b921262a54aea6e1f0d809182f.tar.gz
refactor(storage): Pass cache entries via memory instead of files
Diffstat (limited to 'src/core')
-rw-r--r--src/core/ResultRetriever.cpp8
-rw-r--r--src/core/ResultRetriever.hpp5
2 files changed, 7 insertions, 6 deletions
diff --git a/src/core/ResultRetriever.cpp b/src/core/ResultRetriever.cpp
index b3506f82..89f4389d 100644
--- a/src/core/ResultRetriever.cpp
+++ b/src/core/ResultRetriever.cpp
@@ -44,9 +44,9 @@ namespace core {
using Result::FileType;
ResultRetriever::ResultRetriever(const Context& ctx,
- std::optional<std::string> path)
+ std::optional<Digest> result_key)
: m_ctx(ctx),
- m_path(path)
+ m_result_key(result_key)
{
}
@@ -93,11 +93,11 @@ ResultRetriever::on_raw_file(uint8_t file_number,
Result::file_type_to_string(file_type),
file_size);
- if (!m_path) {
+ if (!m_result_key) {
throw core::Error("Raw entry for non-local result");
}
const auto raw_file_path =
- storage::primary::PrimaryStorage::get_raw_file_path(*m_path, file_number);
+ m_ctx.storage.primary.get_raw_file_path(*m_result_key, file_number);
const auto st = Stat::stat(raw_file_path, Stat::OnError::throw_error);
if (st.size() != file_size) {
throw core::Error(
diff --git a/src/core/ResultRetriever.hpp b/src/core/ResultRetriever.hpp
index d2e814ba..640a761a 100644
--- a/src/core/ResultRetriever.hpp
+++ b/src/core/ResultRetriever.hpp
@@ -20,6 +20,7 @@
#include "Fd.hpp"
+#include <Digest.hpp>
#include <core/Result.hpp>
#include <core/exceptions.hpp>
@@ -41,7 +42,7 @@ public:
//`path` should be the path to the local result entry file if the result comes
// from primary storage.
ResultRetriever(const Context& ctx,
- std::optional<std::string> path = std::nullopt);
+ std::optional<Digest> result_key = std::nullopt);
void on_embedded_file(uint8_t file_number,
Result::FileType file_type,
@@ -52,7 +53,7 @@ public:
private:
const Context& m_ctx;
- std::optional<std::string> m_path;
+ std::optional<Digest> m_result_key;
std::string get_dest_path(Result::FileType file_type) const;