Skip to content

Commit

Permalink
Explicit blacklisting of menu-xdg subfolders
Browse files Browse the repository at this point in the history
Those folders can contain a zoo of orphaned copies of old .desktop
files, added to user's home directories by a faulty tool almost 10 years
ago. The issues from the zombie was actually the trigger to
recursive/non-recursive mode, so now only filter by blacklist and not by
being a sub-folder per-se.
  • Loading branch information
Code7R committed Oct 8, 2024
1 parent 44443c7 commit 4e385c5
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/fdomenu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,13 @@ class FsScan {
function<bool(string &&)> cb;
string sFileNameExtFilter;
bool recursive;
set<string> m_dirBlackList;

public:
FsScan(decltype(FsScan::cb) cb, const string &sFileNameExtFilter = "",
bool recursive = true)
: cb(cb), sFileNameExtFilter(sFileNameExtFilter), recursive(recursive) {
}
set<string> dirBlackList = {}, bool recursive = true)
: cb(cb), sFileNameExtFilter(sFileNameExtFilter), recursive(recursive),
m_dirBlackList(dirBlackList) {}
void scan(const string &sStartdir) { proc_dir_rec(sStartdir); }

private:
Expand Down Expand Up @@ -478,13 +479,15 @@ class FsScan {

if (recursive && S_ISDIR(stbuf.st_mode)) {
process_dir:
// link loop detection
auto prev = make_pair(stbuf.st_ino, stbuf.st_dev);
auto hint = reclog.insert(prev);
if (hint.second) { // we added a new one, otherwise do not
// descend
proc_dir_rec(path + "/" + fname);
reclog.erase(hint.first);
if (m_dirBlackList.find(fname) == m_dirBlackList.end()) {
// link loop detection
auto prev = make_pair(stbuf.st_ino, stbuf.st_dev);
auto hint = reclog.insert(prev);
if (hint.second) { // we added a new one, otherwise do not
// descend
proc_dir_rec(path + "/" + fname);
reclog.erase(hint.first);
}
}
}

Expand Down Expand Up @@ -1126,7 +1129,7 @@ int main(int argc, char **argv) {

return true;
},
".desktop");
".desktop", {"menu-xdg"});

for (const auto &sdir : sharedirs) {
DBGMSG("checkdir: " << sdir);
Expand Down Expand Up @@ -1174,7 +1177,7 @@ int main(int argc, char **argv) {

return true;
},
".directory", false);
".directory", {"menu-xdg"});

for (const auto &sdir : sharedirs) {
dir_loader.scan(sdir + "/desktop-directories");
Expand Down

0 comments on commit 4e385c5

Please sign in to comment.