mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-24 14:56:15 +02:00
Fix read-only copyPathToStore()
This commit is contained in:
parent
95e4376434
commit
eb966921ca
3 changed files with 24 additions and 7 deletions
|
@ -2087,16 +2087,13 @@ StorePath EvalState::copyPathToStore(PathSet & context, const SourcePath & path)
|
|||
auto dstPath = i != srcToStore.end()
|
||||
? i->second
|
||||
: [&]() {
|
||||
#if 0
|
||||
auto p = settings.readOnlyMode
|
||||
? store->computeStorePathForPath(path2.baseName(), canonPath(path)).first
|
||||
: store->addToStore(path2.baseName(), canonPath(path), FileIngestionMethod::Recursive, htSHA256, defaultPathFilter, repair);
|
||||
#endif
|
||||
auto source = sinkToSource([&](Sink & sink) {
|
||||
path.dumpPath(sink);
|
||||
});
|
||||
// FIXME: readOnlyMode
|
||||
auto dstPath = store->addToStoreFromDump(*source, path.baseName(), FileIngestionMethod::Recursive, htSHA256, repair);
|
||||
auto dstPath =
|
||||
settings.readOnlyMode
|
||||
? store->computeStorePathFromDump(*source, path.baseName()).first
|
||||
: store->addToStoreFromDump(*source, path.baseName(), FileIngestionMethod::Recursive, htSHA256, repair);
|
||||
allowPath(dstPath);
|
||||
srcToStore.insert_or_assign(path, dstPath);
|
||||
printMsg(lvlChatty, "copied source '%1%' -> '%2%'", path, store->printStorePath(dstPath));
|
||||
|
|
|
@ -230,6 +230,19 @@ std::pair<StorePath, Hash> Store::computeStorePathForPath(std::string_view name,
|
|||
}
|
||||
|
||||
|
||||
std::pair<StorePath, Hash> Store::computeStorePathFromDump(
|
||||
Source & dump,
|
||||
std::string_view name,
|
||||
FileIngestionMethod method,
|
||||
HashType hashAlgo) const
|
||||
{
|
||||
HashSink sink(hashAlgo);
|
||||
dump.drainInto(sink);
|
||||
auto hash = sink.finish().first;
|
||||
return {makeFixedOutputPath(method, hash, name), hash};
|
||||
}
|
||||
|
||||
|
||||
StorePath Store::computeStorePathForText(
|
||||
std::string_view name,
|
||||
std::string_view s,
|
||||
|
|
|
@ -219,10 +219,17 @@ public:
|
|||
/* This is the preparatory part of addToStore(); it computes the
|
||||
store path to which srcPath is to be copied. Returns the store
|
||||
path and the cryptographic hash of the contents of srcPath. */
|
||||
// FIXME: remove
|
||||
std::pair<StorePath, Hash> computeStorePathForPath(std::string_view name,
|
||||
const Path & srcPath, FileIngestionMethod method = FileIngestionMethod::Recursive,
|
||||
HashType hashAlgo = htSHA256, PathFilter & filter = defaultPathFilter) const;
|
||||
|
||||
std::pair<StorePath, Hash> computeStorePathFromDump(
|
||||
Source & dump,
|
||||
std::string_view name,
|
||||
FileIngestionMethod method = FileIngestionMethod::Recursive,
|
||||
HashType hashAlgo = htSHA256) const;
|
||||
|
||||
/* Preparatory part of addTextToStore().
|
||||
|
||||
!!! Computation of the path should take the references given to
|
||||
|
|
Loading…
Reference in a new issue