Any way to whitelist blog markdown files under git directory?

Tracker ignore git directories by default.

I’m fine with it except for one case: my blog posts are markdown file organized with git, and I want Tracker to index these files so I can do full text search with nautilus.

Any way to whitelist these markdown source file of my blog post?

Hi Julian
You’re right that Tracker ignores git directories by default, via this config setting:

$ gsettings get org.freedesktop.Tracker.Miner.Files ignored-directories-with-content
['.trackerignore', '.git', '.hg', '.nomedia']

To cause Tracker to index files inside a .git directory, you’ll need to remove .git from the list above, like this:

$ gsettings set org.freedesktop.Tracker.Miner.Files ignored-directories-with-content    ['.trackerignore', ' '.hg', '.nomedia']

This does mean that, if you have any other Git directories that you still want Tracker to ignore, you’ll need to explicitly mark them by creating an empty file named .nomedia inside them.

@sthursfield Thanks for your help!

Actually, I mean is there any way to get around this problem without change the behavior of ignore git directories, with something like whitelist mechanism.

Because I only need the one or two folder of my blog to be indexed (folder with name of posts or _posts), while I still have many other git directories that I don’t want to be indexed.

I think there isn’t a way to do exactly that without making code changes to Tracker itself.

The problem with having a way to override the blocklist would be that it becomes harder to reason about whether or not something is blocked when looking at the settings, so while the design of these settings could be improved, it’d need to be done in a way that doesn’t increase their complexity.

As a workaround, you could perhaps hardlink the ‘posts’ directory from your Git directory into another location that Tracker will index.

I read the docs, and found that the directories indexed by Tracker can be control with search settings panel.

So, if I add the directories of my blog source files with this way, would it solve my problem?

I think that if you explicitly add the directories of your blog in this way, then it will indeed cause Tracker to index them, unless they themselves contain the .git directory. I haven’t checked in the code, so I maybe wrong :slight_smile:

@sthursfield How to check whether Tracker have indexed certain folders?

Days after I add the folders with search settings panel, I still can’t do full text search, would this considered as a bug?

Tracker should respond to config changes immediately and should update the index quickly. So it sounds like there is a problem.

The simplest way to check if a location is indexed is to run a command like this in the terminal:

tracker search --files --limit=1000000 |grep 'pathname'

Replace ‘pathname’ with the name of the folder you care about. Note that it’s URL encoded (so spaces are replaced with %20 for example), but you can use only a part of the folder name if that’s easier.

If you get results here, then Tracker has information in the database about those files. If you get no results, then it hasn’t indexed that location.

edit: A more common way to check if a file is indexed or not is to use tracker info $file – I forgot about this when I wrote the post !

This is my setting:

Seems these directories under git folder are still ignored , even if I add them explicitly in search settings panel.

OK, that’s useful info! I must have been wrong in my assumption that explicitly adding the directory would overwrite the ignored-directories-with-content setting.

I would like to see the behaviour of these configuration settings documented somewhere. We don’t currently have much ‘advanced user’ documentation for Tracker, I am keeping this bug open to remind myself to work on that. If/when I get to it, I can try to write something there.

As for whether the current behaviour is correct or not, I don’t have a strong view. The first step is documenting exactly what the current behaviour actually is :slight_smile:

@sthursfield Thanks a lot for you help and detailed explanation!