1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 14:51:16 +02:00

Get rid of LocalStore::addToStoreCommon

I got it to just become `LocalStore::addToStoreFromDump`, cleanly taking
a store and then doing nothing too fancy with it.

`LocalStore::addToStore(...Path...)` is now just a simple wrapper with a
bare-bones sinkToSource of the right dump command.
This commit is contained in:
John Ericson 2020-07-15 23:14:30 +00:00
parent 64b7421741
commit bc109648c4
4 changed files with 67 additions and 58 deletions

View file

@ -256,6 +256,19 @@ struct LambdaSource : Source
}
};
/* Chain two sources together so after the first is exhausted, the second is
used */
struct ChainSource : Source
{
Source & source1, & source2;
bool useSecond = false;
ChainSource(Source & s1, Source & s2)
: source1(s1), source2(s2)
{ }
size_t read(unsigned char * data, size_t len) override;
};
/* Convert a function that feeds data into a Sink into a Source. The
Source executes the function as a coroutine. */
@ -271,7 +284,7 @@ static inline std::unique_ptr<Source> sinkToSource(
throw EndOfFile("coroutine has finished");
})
{
return sinkToSource([fun](Sink & s, size_t & _) { fun(s); }, eof);
return sinkToSource([fun](Sink & s, size_t & _) { fun(s); }, eof);
}