2021-07-26 11:31:09 +00:00
|
|
|
#include "path-info.hh"
|
|
|
|
#include "worker-protocol.hh"
|
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
2023-01-13 20:06:07 +00:00
|
|
|
StorePathSet ValidPathInfo::referencesPossiblyToSelf() const
|
|
|
|
{
|
|
|
|
return references.possiblyToSelf(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ValidPathInfo::insertReferencePossiblyToSelf(StorePath && ref)
|
|
|
|
{
|
|
|
|
return references.insertPossiblyToSelf(path, std::move(ref));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ValidPathInfo::setReferencesPossiblyToSelf(StorePathSet && refs)
|
|
|
|
{
|
|
|
|
return references.setPossiblyToSelf(path, std::move(refs));
|
|
|
|
}
|
|
|
|
|
2021-07-26 11:31:09 +00:00
|
|
|
ValidPathInfo ValidPathInfo::read(Source & source, const Store & store, unsigned int format)
|
|
|
|
{
|
|
|
|
return read(source, store, format, store.parseStorePath(readString(source)));
|
|
|
|
}
|
|
|
|
|
|
|
|
ValidPathInfo ValidPathInfo::read(Source & source, const Store & store, unsigned int format, StorePath && path)
|
|
|
|
{
|
|
|
|
auto deriver = readString(source);
|
|
|
|
auto narHash = Hash::parseAny(readString(source), htSHA256);
|
|
|
|
ValidPathInfo info(path, narHash);
|
|
|
|
if (deriver != "") info.deriver = store.parseStorePath(deriver);
|
2021-09-30 22:36:50 +00:00
|
|
|
info.setReferencesPossiblyToSelf(worker_proto::read(store, source, Phantom<StorePathSet> {}));
|
2021-07-26 11:31:09 +00:00
|
|
|
source >> info.registrationTime >> info.narSize;
|
|
|
|
if (format >= 16) {
|
|
|
|
source >> info.ultimate;
|
|
|
|
info.sigs = readStrings<StringSet>(source);
|
|
|
|
info.ca = parseContentAddressOpt(readString(source));
|
|
|
|
}
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ValidPathInfo::write(
|
|
|
|
Sink & sink,
|
|
|
|
const Store & store,
|
|
|
|
unsigned int format,
|
|
|
|
bool includePath) const
|
|
|
|
{
|
|
|
|
if (includePath)
|
|
|
|
sink << store.printStorePath(path);
|
|
|
|
sink << (deriver ? store.printStorePath(*deriver) : "")
|
|
|
|
<< narHash.to_string(Base16, false);
|
2021-09-30 22:36:50 +00:00
|
|
|
worker_proto::write(store, sink, referencesPossiblyToSelf());
|
2021-07-26 11:31:09 +00:00
|
|
|
sink << registrationTime << narSize;
|
|
|
|
if (format >= 16) {
|
|
|
|
sink << ultimate
|
|
|
|
<< sigs
|
|
|
|
<< renderContentAddress(ca);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|