mirror of
https://github.com/NixOS/nix.git
synced 2025-11-19 16:59:35 +01:00
treewide: Reduce usage of PosixSourceAccessor::createAtRoot
Replaces the usage of createAtRoot, which goes as far up the directory tree as possible with rooted variant makeFSSourceAccessor. The changes in this patch should be safe wrt to not asserting on relative paths. Arguments passed to makeFSSourceAccessor here should already be using absolute paths.
This commit is contained in:
parent
f8141a2c26
commit
436bc1f39e
3 changed files with 7 additions and 12 deletions
|
|
@ -1246,10 +1246,8 @@ StorePath LocalStore::addToStoreFromDump(
|
||||||
|
|
||||||
auto desc = ContentAddressWithReferences::fromParts(
|
auto desc = ContentAddressWithReferences::fromParts(
|
||||||
hashMethod,
|
hashMethod,
|
||||||
methodsMatch
|
methodsMatch ? dumpHash
|
||||||
? dumpHash
|
: hashPath(makeFSSourceAccessor(tempPath), hashMethod.getFileIngestionMethod(), hashAlgo).first,
|
||||||
: hashPath(PosixSourceAccessor::createAtRoot(tempPath), hashMethod.getFileIngestionMethod(), hashAlgo)
|
|
||||||
.first,
|
|
||||||
{
|
{
|
||||||
.others = references,
|
.others = references,
|
||||||
// caller is not capable of creating a self-reference, because this is content-addressed without modulus
|
// 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();
|
checkInterrupt();
|
||||||
auto name = link.path().filename();
|
auto name = link.path().filename();
|
||||||
printMsg(lvlTalkative, "checking contents of %s", name);
|
printMsg(lvlTalkative, "checking contents of %s", name);
|
||||||
std::string hash = hashPath(
|
std::string hash =
|
||||||
PosixSourceAccessor::createAtRoot(link.path()),
|
hashPath(makeFSSourceAccessor(link.path()), FileIngestionMethod::NixArchive, HashAlgorithm::SHA256)
|
||||||
FileIngestionMethod::NixArchive,
|
.first.to_string(HashFormat::Nix32, false);
|
||||||
HashAlgorithm::SHA256)
|
|
||||||
.first.to_string(HashFormat::Nix32, false);
|
|
||||||
if (hash != name.string()) {
|
if (hash != name.string()) {
|
||||||
printError("link %s was modified! expected hash %s, got '%s'", link.path(), name, hash);
|
printError("link %s was modified! expected hash %s, got '%s'", link.path(), name, hash);
|
||||||
if (repair) {
|
if (repair) {
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ void LocalStore::optimisePath_(
|
||||||
auto stLink = lstat(linkPath.string());
|
auto stLink = lstat(linkPath.string());
|
||||||
if (st.st_size != stLink.st_size || (repair && hash != ({
|
if (st.st_size != stLink.st_size || (repair && hash != ({
|
||||||
hashPath(
|
hashPath(
|
||||||
PosixSourceAccessor::createAtRoot(linkPath),
|
makeFSSourceAccessor(linkPath),
|
||||||
FileSerialisationMethod::NixArchive,
|
FileSerialisationMethod::NixArchive,
|
||||||
HashAlgorithm::SHA256)
|
HashAlgorithm::SHA256)
|
||||||
.hash;
|
.hash;
|
||||||
|
|
|
||||||
|
|
@ -138,8 +138,7 @@ std::tuple<StorePath, Hash> prefetchFile(
|
||||||
|
|
||||||
Activity act(*logger, lvlChatty, actUnknown, fmt("adding '%s' to the store", url.to_string()));
|
Activity act(*logger, lvlChatty, actUnknown, fmt("adding '%s' to the store", url.to_string()));
|
||||||
|
|
||||||
auto info = store->addToStoreSlow(
|
auto info = store->addToStoreSlow(*name, makeFSSourceAccessor(tmpFile), method, hashAlgo, {}, expectedHash);
|
||||||
*name, PosixSourceAccessor::createAtRoot(tmpFile), method, hashAlgo, {}, expectedHash);
|
|
||||||
storePath = info.path;
|
storePath = info.path;
|
||||||
assert(info.ca);
|
assert(info.ca);
|
||||||
hash = info.ca->hash;
|
hash = info.ca->hash;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue