mirror of
https://github.com/NixOS/nix
synced 2025-07-03 06:11:46 +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:
parent
9ae6455b0e
commit
fcbc36cf78
13 changed files with 104 additions and 82 deletions
|
@ -108,7 +108,7 @@ struct MountedSSHStoreConfig : virtual SSHStoreConfig, virtual LocalFSStoreConfi
|
|||
{
|
||||
}
|
||||
|
||||
const std::string name() override { return "Experimental SSH Store with filesytem mounted"; }
|
||||
const std::string name() override { return "Experimental SSH Store with filesystem mounted"; }
|
||||
|
||||
std::string doc() override
|
||||
{
|
||||
|
|
|
@ -31,11 +31,11 @@ void SSHMaster::addCommonSSHOpts(Strings & args)
|
|||
if (!keyFile.empty())
|
||||
args.insert(args.end(), {"-i", keyFile});
|
||||
if (!sshPublicHostKey.empty()) {
|
||||
Path fileName = (Path) *state->tmpDir + "/host-key";
|
||||
std::filesystem::path fileName = state->tmpDir->path() / "host-key";
|
||||
auto p = host.rfind("@");
|
||||
std::string thost = p != std::string::npos ? std::string(host, p + 1) : host;
|
||||
writeFile(fileName, thost + " " + base64Decode(sshPublicHostKey) + "\n");
|
||||
args.insert(args.end(), {"-oUserKnownHostsFile=" + fileName});
|
||||
writeFile(fileName.string(), thost + " " + base64Decode(sshPublicHostKey) + "\n");
|
||||
args.insert(args.end(), {"-oUserKnownHostsFile=" + fileName.string()});
|
||||
}
|
||||
if (compress)
|
||||
args.push_back("-C");
|
||||
|
|
|
@ -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)};
|
||||
}
|
||||
|
||||
|
|
|
@ -377,7 +377,7 @@ private:
|
|||
|
||||
void findRuntimeRoots(Roots & roots, bool censor);
|
||||
|
||||
std::pair<Path, AutoCloseFD> createTempDirInStore();
|
||||
std::pair<std::filesystem::path, AutoCloseFD> createTempDirInStore();
|
||||
|
||||
typedef std::unordered_set<ino_t> InodeHash;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue