We have moved to a new Sailfish OS Forum. Please start new discussions there.
55

How to blacklist directories from being indexed by tracker? [answered]

asked 2013-12-29 18:40:58 +0300

datakurre gravatar image

updated 2015-06-23 18:43:55 +0300

chemist gravatar image

Edit: put a file called .nomedia in the folders you do not want to have indexed

To prevent e.g. all the pngs/gifs from random web developer stuff in memory card being indexed and shown e.g. in gallery.

I'm using my phone in developer mode, have symlinked my sdcard under home directory and happen to have directories with gif/png icons, logos and other similar technical graphic files on my sdcard. The problem is that now I see all not only my camera photos but also all technical pngs and other graphics from my sdcard in the gallery app.

I tried to make a good guess and added $HOME/.config/tracker/tracker-miner-fs.cfg, but that was removed as soon as I restarted the miner.

edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by chemist
close date 2015-06-23 18:44:08.087482

Comments

1

Have you tried hidden directories(e.g .icons)? That is the way I do this on N9, but have not tried on Jolla.

zlatko ( 2013-12-29 18:57:31 +0300 )edit

@zlatko Good idea. I'd expect that to work... need to check if that makes sense for all my current use-cases.

datakurre ( 2013-12-29 19:10:20 +0300 )edit
2

@datakurre I actually tried it and it works for me - hidden dirs are not indexed by the tracker.

zlatko ( 2013-12-29 22:12:57 +0300 )edit

check out /usr/bin/tracker-sd-indexing.sh if you feel comfortable to mess with gconf settings :-)

Kontio ( 2013-12-30 00:13:28 +0300 )edit

@Kontio Thanks. It seems that using .-prefixed directories is the easiest way as long as it makes sense for the files in question :)

datakurre ( 2013-12-30 06:40:11 +0300 )edit

4 Answers

Sort by » oldest newest most voted
25

answered 2014-06-23 18:18:16 +0300

updated 2015-06-23 14:09:37 +0300

Hi all, I was digging for a solution to this problem and looking at gsettings I saw that is possible to blacklist folders by simply putting a file named "backup.metadata" in it:

[nemo@Jolla 1311-1208]$ gsettings list-recursively
...
     org.freedesktop.Tracker.Miner.Files ignored-directories-with-content [.nomedia']
...

So I placed this file with:

touch .nomedia

in the folder I do not want to index (osmand map and voice data in my example) and touched the folder so that tracker index it again.

This solution seems to work fine.

Edit: changed backup.medatada with .nomedia

edit flag offensive delete publish link more

Comments

This works instantly for me to remove my ringtones from my media library.

Andy Branson ( 2014-12-15 17:35:03 +0300 )edit
7

With version 1.1.1.27 we have:

org.freedesktop.Tracker.Miner.Files ignored-directories-with-content ['backup.metadata', '.nomedia']

so now we can use hidden file .nomedia

rcasta74 ( 2014-12-22 11:52:44 +0300 )edit

@rcasta thanks, for pointing out, .nomedia sounds much better. Thanks to Jolla as well for being so smart!

magullo ( 2014-12-22 12:08:23 +0300 )edit

@magullo sorry but i don't really understand how it works...
Should i do next:
1. in dev mode open terminal and give "gsettings list-recursively" (dont know what's happened then...
2. Maybe a option file is open and i should put " org.freedesktop.Tracker.Miner.Files ignored-directories-with-content [.nomedia']" and do so that it is stored.
3. place a .nomedia in my folder that i don't want to sync, right?
4. Is there something to be done with the "tracker" (don't know what it is and how we could control it).
Is that the steps to be done for this? thank very much in advance for helping.

cemoi71 ( 2016-01-25 18:21:31 +0300 )edit

@magullo what does it meant with "... and touched the folder so that tracker index it again...." ?

cemoi71 ( 2016-01-25 18:28:07 +0300 )edit
12

answered 2014-09-23 20:36:30 +0300

oku gravatar image

updated 2016-03-16 15:21:29 +0300

virgi26 gravatar image

Exclude directory:

# gsettings set org.freedesktop.Tracker.Miner.Files ignored-directories "['po', 'CVS', 'core-dumps', 'lost+found', '/my/excluded/directory']"

Add directory:

# gsettings set org.freedesktop.Tracker.Miner.Files index-single-directories "['$HOME', '/my/other/directory']"

Or add directory to be indexed recursively:

# gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories "['&DESKTOP', '&DOCUMENTS', '&DOWNLOAD', '&MUSIC', '&PICTURES', '&VIDEOS', '/my/included/directory/tree']"

That works even after reboot. I don't know why adding symlink to ~/Pictures/ doesn't work after reboot for including a directory.

IMO: this should be made possible to do through gallery settings GUI. I just spent too much time just to learn myself around adding android camera directory to my gallery and yet I do nothing else with that information. Also most I found while investigating this, was lots of people trying to do the same without success.

PS created patch for patchmanager https://openrepos.net/content/virgi/patch-tracker-path-settings

edit flag offensive delete publish link more

Comments

1

Exclude directory:

# gsettings set org.freedesktop.Tracker.Miner.Files ignored-directories "['po', 'CVS', 'core-dumps', 'lost+found', '/my/excluded/directory']"

Corrected it for you - it seems the quotation marks are needed "[ ... ]"

ck2nb ( 2014-12-27 15:48:43 +0300 )edit

Fixed that now. :)

oku ( 2015-01-02 15:51:31 +0300 )edit

If I excluded a directory with this command

# gsettings set org.freedesktop.Tracker.Miner.Files ignored-directories "['po', 'CVS', 'core-dumps', 'lost+found', '/my/excluded/directory']"

how can I make it undo?

silta ( 2015-01-09 12:48:26 +0300 )edit

Just use the same string but your added exclude removed. If you didn't understand, see below.

# gsettings set org.freedesktop.Tracker.Miner.Files ignored-directories "['po', 'CVS', 'core-dumps', 'lost+found']"
oku ( 2015-01-09 22:27:54 +0300 )edit

@ck2nb@oku@silta Hello all i don't understand how the trick should work. seems not to be a command to write in dev-mode command-line. Should it be put in a special file or a databank?
Thx in advance for answer

@chemist maybe you too know how does it meant, i have the same problem too. THX

cemoi71 ( 2016-01-25 13:50:21 +0300 )edit
3

answered 2013-12-30 07:07:05 +0300

datakurre gravatar image

Thanks to @zlatko and @Kontio for answers.

Checking out /usr/bin/tracker-sd-indexing.sh shows that indexed directories are whitelisted to contain only the initial content folders (probably Desktop, Documents, Download, Music, Pictures, Videos) and the sdcard (completely).

It seems that you can hide files from being indexed by using non-whitelisted directory names dirctly under /home/nemo or simply prefixing directory names with dot (like .code). Dot-prefix is the only way to hide files on the sdcard.

edit flag offensive delete publish link more

Comments

I use btrfs with subvol on the sd card, subvol for music and video and mount it directly into the Music/Video folder, had to remove sdcard from tracker-sd-indexing.sh

kelvan ( 2014-01-05 19:05:45 +0300 )edit

Need help ! How did you remove sdcard indexing in tracker-sd-indexing.sh ?

fblm ( 2014-02-05 08:30:00 +0300 )edit

I think it would be nice if the user could define the whitelist setting within the mediapalyer.

xneo ( 2014-02-06 12:36:08 +0300 )edit
4

It would be good to have it on a by application basis. I have album art in music folders that I don't want in gallery but do want the music in the player .

skanky ( 2014-12-31 15:08:18 +0300 )edit
3

answered 2014-03-18 21:02:47 +0300

corsarium gravatar image

updated 2014-03-19 03:09:03 +0300

Hi everybody im currently using this script to include/exclude some folders by the tracker. What i did is modify the script /usr/bin/tracker-sd-indexing.sh called during the boot process, but it can be executed at anytime.

The original file

#!/bin/bash

DEF_UID=$(grep "^UID_MIN" /etc/login.defs |  tr -s " " | cut -d " " -f2)

if [ -b /dev/sdcard  ]
then
        if [ "$(gsettings get org.freedesktop.Tracker.Miner.Files index-removable-devices)" = "false" ]
        then
                gsettings set org.freedesktop.Tracker.Miner.Files index-removable-devices true
        fi

        if [ "$(gsettings get org.freedesktop.Tracker.Miner.Files index-recursive-directories | grep extSdCard)" = "" ]
        then
                gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories "['&DESKTOP', '&DOCUMENTS', '&DOWNLOAD', '&MUSIC', '&PICTURES', '&VIDEOS', '/run/user/$DEF_UID/media/sdcard']"
        fi
fi

systemctl --user restart tracker-miner-fs.service

My script.

First of all create 2 files:

  • /home/nemo/.config/tracker/toMount
  • /home/nemo/.config/tracker/toExclude

toMount file

toMountArray="/include/path"

toExclude

toExcludeArray="/excluded/path"

Backup /usr/bin/tracker-sd-indexing.sh

cp  /usr/bin/tracker-sd-indexing.sh  /usr/bin/tracker-sd-indexing.sh_vanilla

Edit /usr/bin/tracker-sd-indexing.sh and add the following content

#!/bin/bash

DEF_UID=`grep "^UID_MIN" /etc/login.defs |  tr -s " " | cut -d " " -f2`
user=`egrep "^[[:alpha:]]+:[[:alpha:]]+:${DEF_UID}" /etc/passwd  | cut -f1 -d ":"`


#add directories to be exclude or include by indexer
toMountFile=/home/$user/.config/tracker/toMount
toExcludeFile=/home/$user/.config/tracker/toExclude


################
#Check mounted and exclude propeties file
toMountFlag=0
toExcludeFlag=0

#if exist and are correct flags = 1
[ -f $toMountFile ]   && . $toMountFile   && toMountFlag=1 
[ -f $toExcludeFile ] && . $toExcludeFile && toExcludeFlag=1 

################
#Check if sdcard is mounted
sdCardFlag=1
sdCardMountPoint=""

grep "^/dev/mmcblk1" /proc/mounts >/dev/null && sdCardFlag=1 




defaults="'&DOWNLOAD', '&MUSIC', '&PICTURES', '&VIDEOS'"


if [ $sdCardFlag -eq 1  ];then
    echo "SD"
    sdCardMountPoint=`grep "^/dev/mmcblk1" /proc/mounts | awk '{print $2}'`

    #Set to true to enable indexing mounted directories for removable devices.
    if [ "$(gsettings get org.freedesktop.Tracker.Miner.Files index-removable-devices)" = "false" ];then
        echo "gsettings set org.freedesktop.Tracker.Miner.Files index-removable-devices true"
        gsettings set org.freedesktop.Tracker.Miner.Files index-removable-devices true
    fi

    #add the toMount array at the end
    if [ $toMountFlag -eq 1 ]; then

        #toMountArray is defined on toMountFile
        if [ -z "$toMountArray" ]; then
            echo "gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories \"[${defaults}, '${sdCardMountPoint}']\""
            gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories "[${defaults}, '${sdCardMountPoint}']"
        else

            toMountString=""
            for i in $toMountArray; do
                toMountString=${toMountString}"'${i}',"
            done

            echo "gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories \"[${defaults}, '${sdCardMountPoint}', ${toMountString%?}]\""
            gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories "[${defaults}, '${sdCardMountPoint}', ${toMountString%''}]"
        fi
    fi
else
    echo "!SD"
    #add the toMount array at the end
    if [ $toMountFlag -eq 1 ]; then

        #toMountArray is defined on toMountFile
        if [ -z "$toMountArray" ]; then
            echo "gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories \"[${defaults}\""
            #gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories "[${defaults}]"
        else

            toMountString=""
            for i in $toMountArray; do
                toMountString=${toMountString}"'${i}',"
            done

            echo "gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories \"[${defaults} ${toMountString%?}]\""
            gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories "[${defaults} ${toMountString%?}]"
        fi
    fi
fi

#add the toexclude array at the end
if [ $toExcludeFlag -eq 1 ]; then

  if [ ! -z "$toExcludeArray" ]; then
    toExcludeString=""
    for i in $toExcludeArray; do
        toExcludeString=${toExcludeString}"'${i}',"
    done
    echo "gsettings set org.freedesktop.Tracker.Miner.Files ignored-directories \"[${toExcludeString%?}]\""
    gsettings set org.freedesktop.Tracker.Miner.Files ignored-directories "[${toExcludeString%?}]"
  fi
fi

echo "systemctl --user restart tracker-miner-fs.service"
systemctl --user restart tracker-miner-fs.service
edit flag offensive delete publish link more

Comments

1

I could need some help here, I don't know since when, but tracker-sd-indexing.sh seems to be gone from /usr/bin and the only file I've found is in /usr/lib/oneshot.d containing the following:

#!/bin/bash
set -e
gsettings set org.freedesktop.Tracker.Miner.Files index-removable-devices true
gsettings set org.freedesktop.Tracker.Miner.Files crawling-interval 0
gsettings set org.freedesktop.Tracker.Miner.Files enable-writeback false
gsettings set org.freedesktop.Tracker.Miner.Files removable-days-threshold 30
gsettings set org.freedesktop.Tracker.Miner.Files index-single-directories "['$HOME']"
gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories "['&DESKTOP', '&DOCUMENTS', '&DOWNLOAD', '&MUSIC', '&PICTURES', '&VIDEOS']"

So, does anybody know, how I can add/remove directories from indexing now?

Thanks i.a.

J4ZZ ( 2014-04-27 16:50:53 +0300 )edit

@oku: You should convert your comment to an answer. It is very helpful and we could vote it up :-)

axaq ( 2014-10-04 17:19:17 +0300 )edit

So I managed to add all the correct tags etc to my music files and moved them (back) to the SD card. I put the .nomedia file in each music dir and whilst I have no album art in the Gallery, the tracker hasn't indexed the MP3's either.... If I rmeove the .nmedia file, the music is happily indexed. Is there a way to enable the music to be indexed without having to remove and readd the .nomedia file ?

lakeboy ( 2017-02-11 11:45:52 +0300 )edit
2

@lakeboy you've captured what all of these different workarounds have missed. There seems to be no way to make tracker index music files, but not index the album art that co-exists in the same directory as the music. The Gallery app should be made to configure this.

The only workaround i can find is to manually delete the music album art from Gallery, which also deletes the album art from the music directories. This seems to work without breaking the album art in Media player, since it keeps its own copy of the art thumbnails, but its still tedious to have to manually delete 1000+ photos from gallery manually (for example). And if you wanted the album art files preserved for some reason its not a viable workaround.

Drekkie ( 2018-03-20 09:44:29 +0300 )edit

Question tools

Follow
28 followers

Stats

Asked: 2013-12-29 18:40:58 +0300

Seen: 6,479 times

Last updated: Mar 16 '16