Package: cruft-ng Version: 0.9.76 Severity: important Tags: patch Dear Maintainer,
* What led up to the situation? Folders that carry lots of files that should be ignored: /.snapshots/ /var/lib/docker/btrfs/subvolumes/ * What exactly did you do (or not do) that was effective The current option removes entries from the output, but clearly does nothing about the process of generating input. * What was the outcome of this action? The process looks at thousands of directories that it should prune. * What outcome did you expect instead? `find -prune` behavior * Code https://salsa.debian.org/pkg-security-team/cruft-ng/-/blame/master/nolocate.cc#L72 ``` diff --git a/nolocate.cc b/nolocate.cc index 0c62cba..c0e6d57 100644 --- a/nolocate.cc +++ b/nolocate.cc @@ -19,6 +19,7 @@ using namespace std; int read_nolocate(vector<string>& fs, const string& ignore_path, const string& root_dir) { bool debug=getenv("DEBUG") != nullptr; + bool is_directory; if (debug) cerr << "FILESYSTEM DATA\n"; @@ -54,6 +55,7 @@ int read_nolocate(vector<string>& fs, const string& ignore_path, const string& r entry.disable_recursion_pending(); bool ignored = false; + is_directory = entry->is_directory(); for (const auto& it : ignores) { if (filename.size() > it.size() && filename.compare(0, it.size(), it) == 0) { ignored = true; @@ -61,15 +63,20 @@ int read_nolocate(vector<string>& fs, const string& ignore_path, const string& r } // ignore directory '/foo' for ignore entry '/foo/' - error_code ec; - if (filename.size() + 1 == it.size() - && it.compare(0, filename.size(), filename) == 0 - && filesystem::is_directory(filename, ec)) { + if (is_directory + // it cannot be empty, filtered when building the list. + && it.back() == '/' + && filename.size() == it.size() - 1 + && it.compare(0, filename.size(), filename) == 0) { ignored = true; break; } } - if (ignored) continue; + if (ignored) { + if (is_directory) + entry.disable_recursion_pending(); + continue; + } if (!pyc_has_py(string{entry->path()}, debug)) fs.emplace_back(filename); ``` -- System Information: Debian Release: 13.1 APT prefers stable-updates APT policy: (515, 'stable-updates'), (515, 'stable-security'), (515, 'stable'), (150, 'testing'), (145, 'unstable'), (135, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 6.17.8-x64v3-xanmod1 (SMP w/8 CPU threads; PREEMPT) Kernel taint flags: TAINT_USER Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /usr/bin/dash Init: systemd (via /run/systemd/system) Versions of packages cruft-ng depends on: ii libc6 2.41-12 ii libgcc-s1 15.2.0-7 ii libmd0 1.1.0-2+b1 ii libstdc++6 15.2.0-7 cruft-ng recommends no packages. Versions of packages cruft-ng suggests: pn ncdu <none> -- no debconf information

