1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-29 13:41:00 +01:00

Fix read-only copyPathToStore()

This commit is contained in:
Eelco Dolstra 2022-05-11 14:22:18 +02:00
parent 95e4376434
commit eb966921ca
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
3 changed files with 24 additions and 7 deletions

View file

@ -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,

View file

@ -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