albert icon indicating copy to clipboard operation
albert copied to clipboard

[files] Excluding certain folders

Open palmenros opened this issue 4 years ago • 8 comments

Why?

Right now the files extension allows you to add folders to index. However, it's common for modern developing tools to have huge folders such as 'node_modules' or 'venv' or 'vendor' which pollute the search. It would be great if we could add a list of excluded folders (maybe in the form of regex, maybe in the form of exact match) so that the indexer wouldn't go inside them.

How?

I don't exactly know how the indexer is built, but it shouldn't be too hard to check that the current folder name is not a "blacklisted folder name" before recursing into indexing it.

palmenros avatar Oct 18 '21 20:10 palmenros

Read the docs or simply Google ".albertignore"

ManuelSchneid3r avatar Oct 18 '21 20:10 ManuelSchneid3r

After reading about .albertignore (the doc linked https://albertlauncher.github.io/docs/extensions/files/ doesn't work anymore) I cannot get it to ignore every subfolder (no matter the nesting) with some name. That would be very useful as right now I have to manually add a .albertignore (or add a line to an existing .albertignore) while the ideal way would be having a root .albertignore who would ignore all node_modules (no matter how deeply nested they are in the folder structure).

palmenros avatar Oct 18 '21 22:10 palmenros

see https://github.com/albertlauncher/plugins/tree/master/files

Sure a single line node_modules should work. Note beginning with a slash makes the path relative to the root. /node_modules ignores only $ROOTPATH/node_modules and ignores the nested dir. Correct me if im wrong. Them this is a bug.

ManuelSchneid3r avatar Nov 05 '21 17:11 ManuelSchneid3r

I think this is indeed a bug. Placing a .albertignore file with content node_modules (no /s or *s) in a directory with many nested node_modules still indexes folders and files within them. Refreshing the index via the "Start Scan" button or restarting Albert doesn't seem to update it either.

Bentheburrito avatar Dec 11 '21 23:12 Bentheburrito

also i'm able to reproduce this issue, if there is too many nesting for a wildcard it fails.

m8 avatar Dec 19 '21 13:12 m8

This seems to be the function/recursive call that handles the ignored paths. It looks like localIgnoreEntries is passed to the child nodes, too, so I'm not sure why nested file ignores aren't working (though I'm not very familiar with C++, so I'm likely missing something if the problem is indeed in this function :eyes:)

Bentheburrito avatar Jan 01 '22 19:01 Bentheburrito

I have the same problem. For example, adding a file into the parent for excluding node_modules. Still, I see searching inside the children for node_modules This is really important to fix..

MuhametSmaili avatar Sep 06 '22 19:09 MuhametSmaili

This worked for me:

  • Delete ~/.cache/albert/org.albert.extension.files/fileindex.json (should probably close Albert first)
  • Create .albertignore in the home directory and add the following: /**/node_modules/**

nywilds avatar Sep 13 '22 03:09 nywilds