|
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 |
|
@@ -142,4 +142,47 @@ void WorkerProto::Serialise<BuildResult>::write(const Store & store, WorkerProto |
142 | 142 | } |
143 | 143 |
|
144 | 144 |
|
| 145 | +ValidPathInfo WorkerProto::Serialise<ValidPathInfo>::read(const Store & store, ReadConn conn) |
| 146 | +{ |
| 147 | + auto path = WorkerProto::Serialise<StorePath>::read(store, conn); |
| 148 | + return WorkerProto::Serialise<ValidPathInfo>::read(store, conn, std::move(path)); |
| 149 | +} |
| 150 | + |
| 151 | +ValidPathInfo WorkerProto::Serialise<ValidPathInfo>::read(const Store & store, ReadConn conn, StorePath && path) |
| 152 | +{ |
| 153 | + auto deriver = readString(conn.from); |
| 154 | + auto narHash = Hash::parseAny(readString(conn.from), htSHA256); |
| 155 | + ValidPathInfo info(path, narHash); |
| 156 | + if (deriver != "") info.deriver = store.parseStorePath(deriver); |
| 157 | + info.references = WorkerProto::Serialise<StorePathSet>::read(store, conn); |
| 158 | + conn.from >> info.registrationTime >> info.narSize; |
| 159 | + if (GET_PROTOCOL_MINOR(conn.version) >= 16) { |
| 160 | + conn.from >> info.ultimate; |
| 161 | + info.sigs = readStrings<StringSet>(conn.from); |
| 162 | + info.ca = ContentAddress::parseOpt(readString(conn.from)); |
| 163 | + } |
| 164 | + return info; |
| 165 | +} |
| 166 | + |
| 167 | +void WorkerProto::Serialise<ValidPathInfo>::write( |
| 168 | + const Store & store, |
| 169 | + WriteConn conn, |
| 170 | + const ValidPathInfo & pathInfo, |
| 171 | + bool includePath) |
| 172 | +{ |
| 173 | + if (includePath) |
| 174 | + conn.to << store.printStorePath(pathInfo.path); |
| 175 | + conn.to |
| 176 | + << (pathInfo.deriver ? store.printStorePath(*pathInfo.deriver) : "") |
| 177 | + << pathInfo.narHash.to_string(Base16, false); |
| 178 | + WorkerProto::write(store, conn, pathInfo.references); |
| 179 | + conn.to << pathInfo.registrationTime << pathInfo.narSize; |
| 180 | + if (GET_PROTOCOL_MINOR(conn.version) >= 16) { |
| 181 | + conn.to |
| 182 | + << pathInfo.ultimate |
| 183 | + << pathInfo.sigs |
| 184 | + << renderContentAddress(pathInfo.ca); |
| 185 | + } |
| 186 | +} |
| 187 | + |
145 | 188 | } |
0 commit comments