1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-29 10:31:15 +02:00

Use std::filesystem::path in more places (#10657)

Progress on #9205

Co-Authored-By: John Ericson <John.Ericson@Obsidian.Systems>

* Get rid of `PathNG`, just use `std::filesystem::path`
This commit is contained in:
Siddhant Kumar 2024-05-08 03:58:50 +05:30 committed by GitHub
parent 9ae6455b0e
commit fcbc36cf78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 104 additions and 82 deletions

View file

@ -1220,8 +1220,8 @@ StorePath LocalStore::addToStoreFromDump(
}
std::unique_ptr<AutoDelete> delTempDir;
Path tempPath;
Path tempDir;
std::filesystem::path tempPath;
std::filesystem::path tempDir;
AutoCloseFD tempDirFd;
bool methodsMatch = ContentAddressMethod(FileIngestionMethod(dumpMethod)) == hashMethod;
@ -1237,9 +1237,9 @@ StorePath LocalStore::addToStoreFromDump(
std::tie(tempDir, tempDirFd) = createTempDirInStore();
delTempDir = std::make_unique<AutoDelete>(tempDir);
tempPath = tempDir + "/x";
tempPath = tempDir / "x";
restorePath(tempPath, bothSource, dumpMethod);
restorePath(tempPath.string(), bothSource, dumpMethod);
dumpBuffer.reset();
dump = {};
@ -1252,7 +1252,7 @@ StorePath LocalStore::addToStoreFromDump(
methodsMatch
? dumpHash
: hashPath(
{getFSSourceAccessor(), CanonPath(tempPath)},
PosixSourceAccessor::createAtRoot(tempPath),
hashMethod.getFileIngestionMethod(), hashAlgo),
{
.others = references,
@ -1295,7 +1295,7 @@ StorePath LocalStore::addToStoreFromDump(
}
} else {
/* Move the temporary path we restored above. */
moveFile(tempPath, realPath);
moveFile(tempPath.string(), realPath);
}
/* For computing the nar hash. In recursive SHA-256 mode, this
@ -1330,9 +1330,9 @@ StorePath LocalStore::addToStoreFromDump(
/* Create a temporary directory in the store that won't be
garbage-collected until the returned FD is closed. */
std::pair<Path, AutoCloseFD> LocalStore::createTempDirInStore()
std::pair<std::filesystem::path, AutoCloseFD> LocalStore::createTempDirInStore()
{
Path tmpDirFn;
std::filesystem::path tmpDirFn;
AutoCloseFD tmpDirFd;
bool lockedByUs = false;
do {
@ -1345,7 +1345,7 @@ std::pair<Path, AutoCloseFD> LocalStore::createTempDirInStore()
continue;
}
lockedByUs = lockFile(tmpDirFd.get(), ltWrite, true);
} while (!pathExists(tmpDirFn) || !lockedByUs);
} while (!pathExists(tmpDirFn.string()) || !lockedByUs);
return {tmpDirFn, std::move(tmpDirFd)};
}