|
6 | 6 | #include "worker-protocol.hh" |
7 | 7 | #include "worker-protocol-impl.hh" |
8 | 8 | #include "archive.hh" |
9 | | -#include "derivations.hh" |
| 9 | +#include "path-info.hh" |
10 | 10 |
|
11 | 11 | #include <nlohmann/json.hpp> |
12 | 12 |
|
@@ -44,5 +44,48 @@ void write(const Store & store, WriteConn conn, const BuildResult & res) |
44 | 44 | } |
45 | 45 |
|
46 | 46 |
|
| 47 | +ValidPathInfo readValidPathInfo(const Store & store, ReadConn conn) |
| 48 | +{ |
| 49 | + auto path = read(store, conn, Phantom<StorePath>{}); |
| 50 | + return readValidPathInfo(store, conn, std::move(path)); |
| 51 | +} |
| 52 | + |
| 53 | +ValidPathInfo readValidPathInfo(const Store & store, ReadConn conn, StorePath && path) |
| 54 | +{ |
| 55 | + auto deriver = readString(conn.from); |
| 56 | + auto narHash = Hash::parseAny(readString(conn.from), htSHA256); |
| 57 | + ValidPathInfo info(path, narHash); |
| 58 | + if (deriver != "") info.deriver = store.parseStorePath(deriver); |
| 59 | + info.references = read(store, conn, Phantom<StorePathSet> {}); |
| 60 | + conn.from >> info.registrationTime >> info.narSize; |
| 61 | + if (GET_PROTOCOL_MINOR(conn.version) >= 16) { |
| 62 | + conn.from >> info.ultimate; |
| 63 | + info.sigs = readStrings<StringSet>(conn.from); |
| 64 | + info.ca = parseContentAddressOpt(readString(conn.from)); |
| 65 | + } |
| 66 | + return info; |
| 67 | +} |
| 68 | + |
| 69 | +void write( |
| 70 | + const Store & store, |
| 71 | + WriteConn conn, |
| 72 | + const ValidPathInfo & pathInfo, |
| 73 | + bool includePath) |
| 74 | +{ |
| 75 | + if (includePath) |
| 76 | + conn.to << store.printStorePath(pathInfo.path); |
| 77 | + conn.to |
| 78 | + << (pathInfo.deriver ? store.printStorePath(*pathInfo.deriver) : "") |
| 79 | + << pathInfo.narHash.to_string(Base16, false); |
| 80 | + write(store, conn, pathInfo.references); |
| 81 | + conn.to << pathInfo.registrationTime << pathInfo.narSize; |
| 82 | + if (GET_PROTOCOL_MINOR(conn.version) >= 16) { |
| 83 | + conn.to |
| 84 | + << pathInfo.ultimate |
| 85 | + << pathInfo.sigs |
| 86 | + << renderContentAddress(pathInfo.ca); |
| 87 | + } |
| 88 | +} |
| 89 | + |
47 | 90 | } |
48 | 91 | } |
0 commit comments