wopAddToStore: add RepairFlag

This commit is contained in:
Robert Hensing 2020-09-18 10:06:34 +02:00
parent fbf509c113
commit 7c68264085
3 changed files with 9 additions and 7 deletions

View file

@ -353,6 +353,9 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
auto name = readString(from);
auto camStr = readString(from);
auto refs = readStorePaths<StorePathSet>(*store, from);
bool repairBool;
from >> repairBool;
auto repair = RepairFlag{repairBool};
logger->startWork();
StorePath path = [&]() -> StorePath {
@ -368,7 +371,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
[&](FixedOutputHashMethod &fohm) -> StorePath {
if (!refs.empty())
throw UnimplementedError("cannot yet have refs with flat or nar-hashed data");
return store->addToStoreFromDump(source, name, fohm.fileIngestionMethod, fohm.hashType);
return store->addToStoreFromDump(source, name, fohm.fileIngestionMethod, fohm.hashType, repair);
},
}, contentAddressMethod);
}();

View file

@ -526,7 +526,7 @@ std::optional<StorePath> RemoteStore::queryPathFromHashPart(const std::string &
}
StorePath RemoteStore::addCAToStore(Source & dump, const string & name, ContentAddressMethod caMethod, StorePathSet references)
StorePath RemoteStore::addCAToStore(Source & dump, const string & name, ContentAddressMethod caMethod, StorePathSet references, RepairFlag repair)
{
auto conn(getConnection());
@ -537,6 +537,7 @@ StorePath RemoteStore::addCAToStore(Source & dump, const string & name, ContentA
<< name
<< renderContentAddressMethod(caMethod);
writeStorePaths(*this, conn->to, references);
conn->to << repair;
conn.withFramedSink([&](Sink & sink) {
dump.drainInto(sink);
@ -597,9 +598,8 @@ StorePath RemoteStore::addCAToStore(Source & dump, const string & name, ContentA
StorePath RemoteStore::addToStoreFromDump(Source & dump, const string & name,
FileIngestionMethod method, HashType hashType, RepairFlag repair)
{
if (repair) throw Error("repairing is not supported when adding to store through the Nix daemon");
StorePathSet references;
return addCAToStore(dump, name, FixedOutputHashMethod{ .fileIngestionMethod = method, .hashType = hashType }, references);
return addCAToStore(dump, name, FixedOutputHashMethod{ .fileIngestionMethod = method, .hashType = hashType }, references, repair);
}
@ -659,9 +659,8 @@ void RemoteStore::addToStore(const ValidPathInfo & info, Source & source,
StorePath RemoteStore::addTextToStore(const string & name, const string & s,
const StorePathSet & references, RepairFlag repair)
{
if (repair) throw Error("repairing is not supported when building through the Nix daemon");
StringSource source(s);
return addCAToStore(source, name, TextHashMethod{}, references);
return addCAToStore(source, name, TextHashMethod{}, references, repair);
}

View file

@ -63,7 +63,7 @@ public:
void querySubstitutablePathInfos(const StorePathCAMap & paths,
SubstitutablePathInfos & infos) override;
StorePath addCAToStore(Source & dump, const string & name, ContentAddressMethod caMethod, StorePathSet references);
StorePath addCAToStore(Source & dump, const string & name, ContentAddressMethod caMethod, StorePathSet references, RepairFlag repair);
StorePath addToStoreFromDump(Source & dump, const string & name,
FileIngestionMethod method = FileIngestionMethod::Recursive, HashType hashAlgo = htSHA256, RepairFlag repair = NoRepair) override;