mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 11:36:03 +01:00
Fixup issues with bytes
This commit is contained in:
parent
b41ce0d263
commit
c893454926
2 changed files with 6 additions and 4 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
#include "nix/util/bytes.hh"
|
||||||
#include "nix/util/memory-source-accessor.hh"
|
#include "nix/util/memory-source-accessor.hh"
|
||||||
#include "nix/store/dummy-store-impl.hh"
|
#include "nix/store/dummy-store-impl.hh"
|
||||||
#include "nix/store/globals.hh"
|
#include "nix/store/globals.hh"
|
||||||
|
|
@ -105,7 +106,7 @@ INSTANTIATE_TEST_SUITE_P(DummyStoreJSON, DummyStoreJsonTest, [] {
|
||||||
auto sc = make_ref<MemorySourceAccessor>();
|
auto sc = make_ref<MemorySourceAccessor>();
|
||||||
sc->root = MemorySourceAccessor::File{MemorySourceAccessor::File::Regular{
|
sc->root = MemorySourceAccessor::File{MemorySourceAccessor::File::Regular{
|
||||||
.executable = false,
|
.executable = false,
|
||||||
.contents = "asdf",
|
.contents = to_owned(as_bytes("asdf")),
|
||||||
}};
|
}};
|
||||||
return sc;
|
return sc;
|
||||||
}(),
|
}(),
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "nix/store/store-registration.hh"
|
#include "nix/store/store-registration.hh"
|
||||||
#include "nix/util/archive.hh"
|
#include "nix/util/archive.hh"
|
||||||
|
#include "nix/util/bytes.hh"
|
||||||
#include "nix/util/callback.hh"
|
#include "nix/util/callback.hh"
|
||||||
#include "nix/util/memory-source-accessor.hh"
|
#include "nix/util/memory-source-accessor.hh"
|
||||||
#include "nix/util/json-utils.hh"
|
#include "nix/util/json-utils.hh"
|
||||||
|
|
@ -160,7 +161,7 @@ struct DummyStoreImpl : DummyStore
|
||||||
.method = ContentAddressMethod::Raw::Text,
|
.method = ContentAddressMethod::Raw::Text,
|
||||||
.hash = hashString(
|
.hash = hashString(
|
||||||
HashAlgorithm::SHA256,
|
HashAlgorithm::SHA256,
|
||||||
std::get<MemorySourceAccessor::File::Regular>(accessor->root->raw).contents),
|
to_str(std::get<MemorySourceAccessor::File::Regular>(accessor->root->raw).contents)),
|
||||||
};
|
};
|
||||||
callback(std::move(info));
|
callback(std::move(info));
|
||||||
return;
|
return;
|
||||||
|
|
@ -428,7 +429,7 @@ ref<DummyStore> adl_serializer<ref<DummyStore>>::from_json(const json & json)
|
||||||
auto vref = make_ref<UnkeyedRealisation>(v2);
|
auto vref = make_ref<UnkeyedRealisation>(v2);
|
||||||
res->buildTrace.insert_or_visit(
|
res->buildTrace.insert_or_visit(
|
||||||
{
|
{
|
||||||
Hash::parseExplicitFormatUnprefixed(k0, HashAlgorithm::SHA256, HashFormat::Base64),
|
StorePath{k0},
|
||||||
{{k1, vref}},
|
{{k1, vref}},
|
||||||
},
|
},
|
||||||
[&](auto & kv) { kv.second.insert_or_assign(k1, vref); });
|
[&](auto & kv) { kv.second.insert_or_assign(k1, vref); });
|
||||||
|
|
@ -464,7 +465,7 @@ void adl_serializer<ref<DummyStore>>::to_json(json & json, const ref<DummyStore>
|
||||||
auto obj = json::object();
|
auto obj = json::object();
|
||||||
val->buildTrace.cvisit_all([&](const auto & kv) {
|
val->buildTrace.cvisit_all([&](const auto & kv) {
|
||||||
auto & [k, v] = kv;
|
auto & [k, v] = kv;
|
||||||
auto & obj2 = obj[k.to_string(HashFormat::Base64, false)] = json::object();
|
auto & obj2 = obj[k.to_string()] = json::object();
|
||||||
for (auto & [k2, v2] : kv.second)
|
for (auto & [k2, v2] : kv.second)
|
||||||
obj2[k2] = *v2;
|
obj2[k2] = *v2;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue