mirror of
https://github.com/NixOS/nix.git
synced 2025-11-19 16:59:35 +01:00
Merge pull request #14586 from NixOS/less-create-at-root
treewide: Reduce usage of PosixSourceAccessor::createAtRoot
This commit is contained in:
commit
7721fa6df4
3 changed files with 7 additions and 12 deletions
|
|
@ -1246,10 +1246,8 @@ StorePath LocalStore::addToStoreFromDump(
|
|||
|
||||
auto desc = ContentAddressWithReferences::fromParts(
|
||||
hashMethod,
|
||||
methodsMatch
|
||||
? dumpHash
|
||||
: hashPath(PosixSourceAccessor::createAtRoot(tempPath), hashMethod.getFileIngestionMethod(), hashAlgo)
|
||||
.first,
|
||||
methodsMatch ? dumpHash
|
||||
: hashPath(makeFSSourceAccessor(tempPath), hashMethod.getFileIngestionMethod(), hashAlgo).first,
|
||||
{
|
||||
.others = references,
|
||||
// caller is not capable of creating a self-reference, because this is content-addressed without modulus
|
||||
|
|
@ -1385,11 +1383,9 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
|
|||
checkInterrupt();
|
||||
auto name = link.path().filename();
|
||||
printMsg(lvlTalkative, "checking contents of %s", name);
|
||||
std::string hash = hashPath(
|
||||
PosixSourceAccessor::createAtRoot(link.path()),
|
||||
FileIngestionMethod::NixArchive,
|
||||
HashAlgorithm::SHA256)
|
||||
.first.to_string(HashFormat::Nix32, false);
|
||||
std::string hash =
|
||||
hashPath(makeFSSourceAccessor(link.path()), FileIngestionMethod::NixArchive, HashAlgorithm::SHA256)
|
||||
.first.to_string(HashFormat::Nix32, false);
|
||||
if (hash != name.string()) {
|
||||
printError("link %s was modified! expected hash %s, got '%s'", link.path(), name, hash);
|
||||
if (repair) {
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ void LocalStore::optimisePath_(
|
|||
auto stLink = lstat(linkPath.string());
|
||||
if (st.st_size != stLink.st_size || (repair && hash != ({
|
||||
hashPath(
|
||||
PosixSourceAccessor::createAtRoot(linkPath),
|
||||
makeFSSourceAccessor(linkPath),
|
||||
FileSerialisationMethod::NixArchive,
|
||||
HashAlgorithm::SHA256)
|
||||
.hash;
|
||||
|
|
|
|||
|
|
@ -138,8 +138,7 @@ std::tuple<StorePath, Hash> prefetchFile(
|
|||
|
||||
Activity act(*logger, lvlChatty, actUnknown, fmt("adding '%s' to the store", url.to_string()));
|
||||
|
||||
auto info = store->addToStoreSlow(
|
||||
*name, PosixSourceAccessor::createAtRoot(tmpFile), method, hashAlgo, {}, expectedHash);
|
||||
auto info = store->addToStoreSlow(*name, makeFSSourceAccessor(tmpFile), method, hashAlgo, {}, expectedHash);
|
||||
storePath = info.path;
|
||||
assert(info.ca);
|
||||
hash = info.ca->hash;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue