mirror of
https://github.com/NixOS/nix
synced 2025-07-03 06:11:46 +02:00
add call to checkInterrupt
in a bunch of places
This brings back the old behaviour. We check for interrupts in places that may iterate over wide directories.
This commit is contained in:
parent
1623249745
commit
8f1a26667e
13 changed files with 29 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
|||
#include "buildenv.hh"
|
||||
#include "derivations.hh"
|
||||
#include "signals.hh"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -30,6 +31,7 @@ static void createLinks(State & state, const Path & srcDir, const Path & dstDir,
|
|||
}
|
||||
|
||||
for (const auto & ent : srcFiles) {
|
||||
checkInterrupt();
|
||||
auto name = ent.path().filename();
|
||||
if (name.string()[0] == '.')
|
||||
/* not matched by glob */
|
||||
|
|
|
@ -162,6 +162,7 @@ void LocalStore::findTempRoots(Roots & tempRoots, bool censor)
|
|||
/* Read the `temproots' directory for per-process temporary root
|
||||
files. */
|
||||
for (auto & i : std::filesystem::directory_iterator{tempRootsDir}) {
|
||||
checkInterrupt();
|
||||
auto name = i.path().filename().string();
|
||||
if (name[0] == '.') {
|
||||
// Ignore hidden files. Some package managers (notably portage) create
|
||||
|
@ -228,8 +229,10 @@ void LocalStore::findRoots(const Path & path, std::filesystem::file_type type, R
|
|||
type = std::filesystem::symlink_status(path).type();
|
||||
|
||||
if (type == std::filesystem::file_type::directory) {
|
||||
for (auto & i : std::filesystem::directory_iterator{path})
|
||||
for (auto & i : std::filesystem::directory_iterator{path}) {
|
||||
checkInterrupt();
|
||||
findRoots(i.path().string(), i.symlink_status().type(), roots);
|
||||
}
|
||||
}
|
||||
|
||||
else if (type == std::filesystem::file_type::symlink) {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "args.hh"
|
||||
#include "abstract-setting-to-json.hh"
|
||||
#include "compute-levels.hh"
|
||||
#include "signals.hh"
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
|
@ -346,14 +347,17 @@ void initPlugins()
|
|||
std::vector<std::filesystem::path> pluginFiles;
|
||||
try {
|
||||
auto ents = std::filesystem::directory_iterator{pluginFile};
|
||||
for (const auto & ent : ents)
|
||||
for (const auto & ent : ents) {
|
||||
checkInterrupt();
|
||||
pluginFiles.emplace_back(ent.path());
|
||||
}
|
||||
} catch (std::filesystem::filesystem_error & e) {
|
||||
if (e.code() != std::errc::not_a_directory)
|
||||
throw;
|
||||
pluginFiles.emplace_back(pluginFile);
|
||||
}
|
||||
for (const auto & file : pluginFiles) {
|
||||
checkInterrupt();
|
||||
/* handle is purposefully leaked as there may be state in the
|
||||
DSO needed by the action of the plugin. */
|
||||
#ifndef _WIN32 // TODO implement via DLL loading on Windows
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "binary-cache-store.hh"
|
||||
#include "globals.hh"
|
||||
#include "nar-info-disk-cache.hh"
|
||||
#include "signals.hh"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
|
@ -84,6 +85,7 @@ protected:
|
|||
StorePathSet paths;
|
||||
|
||||
for (auto & entry : std::filesystem::directory_iterator{binaryCacheDir}) {
|
||||
checkInterrupt();
|
||||
auto name = entry.path().filename().string();
|
||||
if (name.size() != 40 ||
|
||||
!hasSuffix(name, ".narinfo"))
|
||||
|
|
|
@ -1407,6 +1407,7 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
|
|||
printInfo("checking link hashes...");
|
||||
|
||||
for (auto & link : std::filesystem::directory_iterator{linksDir}) {
|
||||
checkInterrupt();
|
||||
auto name = link.path().filename();
|
||||
printMsg(lvlTalkative, "checking contents of '%s'", name);
|
||||
PosixSourceAccessor accessor;
|
||||
|
@ -1499,6 +1500,7 @@ LocalStore::VerificationResult LocalStore::verifyAllValidPaths(RepairFlag repair
|
|||
invalid states.
|
||||
*/
|
||||
for (auto & i : std::filesystem::directory_iterator{realStoreDir.to_string()}) {
|
||||
checkInterrupt();
|
||||
try {
|
||||
storePathsInStoreDir.insert({i.path().filename().string()});
|
||||
} catch (BadStorePath &) { }
|
||||
|
|
|
@ -144,13 +144,15 @@ static void canonicalisePathMetaData_(
|
|||
#endif
|
||||
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
for (auto & i : std::filesystem::directory_iterator{path})
|
||||
for (auto & i : std::filesystem::directory_iterator{path}) {
|
||||
checkInterrupt();
|
||||
canonicalisePathMetaData_(
|
||||
i.path().string(),
|
||||
#ifndef _WIN32
|
||||
uidRange,
|
||||
#endif
|
||||
inodesSeen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "profiles.hh"
|
||||
#include "signals.hh"
|
||||
#include "store-api.hh"
|
||||
#include "local-fs-store.hh"
|
||||
#include "users.hh"
|
||||
|
@ -38,6 +39,7 @@ std::pair<Generations, std::optional<GenerationNumber>> findGenerations(Path pro
|
|||
auto profileName = std::string(baseNameOf(profile));
|
||||
|
||||
for (auto & i : std::filesystem::directory_iterator{profileDir}) {
|
||||
checkInterrupt();
|
||||
if (auto n = parseName(profileName, i.path().filename().string())) {
|
||||
auto path = i.path().string();
|
||||
gens.push_back({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue