Skip to content

Commit 7721fa6

Browse files
authored
Merge pull request NixOS#14586 from NixOS/less-create-at-root
treewide: Reduce usage of PosixSourceAccessor::createAtRoot
2 parents cb5d97a + 436bc1f commit 7721fa6

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

src/libstore/local-store.cc

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,10 +1246,8 @@ StorePath LocalStore::addToStoreFromDump(
12461246

12471247
auto desc = ContentAddressWithReferences::fromParts(
12481248
hashMethod,
1249-
methodsMatch
1250-
? dumpHash
1251-
: hashPath(PosixSourceAccessor::createAtRoot(tempPath), hashMethod.getFileIngestionMethod(), hashAlgo)
1252-
.first,
1249+
methodsMatch ? dumpHash
1250+
: hashPath(makeFSSourceAccessor(tempPath), hashMethod.getFileIngestionMethod(), hashAlgo).first,
12531251
{
12541252
.others = references,
12551253
// 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)
13851383
checkInterrupt();
13861384
auto name = link.path().filename();
13871385
printMsg(lvlTalkative, "checking contents of %s", name);
1388-
std::string hash = hashPath(
1389-
PosixSourceAccessor::createAtRoot(link.path()),
1390-
FileIngestionMethod::NixArchive,
1391-
HashAlgorithm::SHA256)
1392-
.first.to_string(HashFormat::Nix32, false);
1386+
std::string hash =
1387+
hashPath(makeFSSourceAccessor(link.path()), FileIngestionMethod::NixArchive, HashAlgorithm::SHA256)
1388+
.first.to_string(HashFormat::Nix32, false);
13931389
if (hash != name.string()) {
13941390
printError("link %s was modified! expected hash %s, got '%s'", link.path(), name, hash);
13951391
if (repair) {

src/libstore/optimise-store.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void LocalStore::optimisePath_(
172172
auto stLink = lstat(linkPath.string());
173173
if (st.st_size != stLink.st_size || (repair && hash != ({
174174
hashPath(
175-
PosixSourceAccessor::createAtRoot(linkPath),
175+
makeFSSourceAccessor(linkPath),
176176
FileSerialisationMethod::NixArchive,
177177
HashAlgorithm::SHA256)
178178
.hash;

src/nix/prefetch.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ std::tuple<StorePath, Hash> prefetchFile(
138138

139139
Activity act(*logger, lvlChatty, actUnknown, fmt("adding '%s' to the store", url.to_string()));
140140

141-
auto info = store->addToStoreSlow(
142-
*name, PosixSourceAccessor::createAtRoot(tmpFile), method, hashAlgo, {}, expectedHash);
141+
auto info = store->addToStoreSlow(*name, makeFSSourceAccessor(tmpFile), method, hashAlgo, {}, expectedHash);
143142
storePath = info.path;
144143
assert(info.ca);
145144
hash = info.ca->hash;

0 commit comments

Comments
 (0)