Best practices with .nomedia

Hi everyone!

What are currently considered the best practices in using .nomedia touch files (to avoid media being indexed)?

  • should SailfishOS native applications drop their own files? (I’ve seen a few Android apps doing exactly that)
  • should we leave it to the end user to decide and create the files themselves?

Context:
Stellarium comes with a very large amount of pictures (backgrounds, constellations in various cultures, etc.) which “pollute” the Gallery.
So:

  • Should I upgrade the .spec file so the RPM drops a .nomedia inside Stellarium’s datadir ?
3 Likes

Only /home is indexed. You should not install anything to /home. If that files are installed by an app running by user it should be an option in app settings that allows to index pictures from datadir or not. Average user knows nothing about .nomedia files but always cares about “polluted” Gallery.

2 Likes

In this specific case, /run/media/ is also indexed, and offloading datadir to SD card + symlink in /usr/share is a popular procedure.

1 Like

So I guess the ‘pollution’ only happens to users who have done that sdcard move? Otherwise data is in /usr/share and thus not indexed?

2 Likes

An alternative could be to make the app configure Tracker via dconf/gsettings to ignore that storage area.

This way it could be made configurable per-user.

https://wiki.gnome.org/Projects/Tracker/Documentation/Configuration

org.freedesktop.Tracker3.Miner.Files ignored-directories ['po', 'CVS', 'core-dumps', 'lost+found', '$HOME/android_storage/Android']

2 Likes

I can’t remember the thread, but there was a suggestion of installing to /home/.system/ …

But if a ‘.nomedia’ file works, that’s a simple solution. Why not?

For Stellearium I had simply moved the files to :slight_smile:

.local/share/me.lduboeuf.stellarium/stellarium/

and generated symlinks in the application folder:

data → /home/defaultuser/.local/share/me.lduboeuf.stellarium/stellarium/data

Should end user is skilled enough to create symlink then is skilled enough to create .nomedia and take care of “pollution” themselves.

2 Likes

It is?
Seems wrong to me. On a stationary GNU/Linux it used to be relatively common to mount /usr/share from a different partition, but that is not the same as abusing a user-mounted SDCard for that. Expand your root partition instead.

In any case, you are free to drop a .nomedia in /usr/share top level directory (wherever that is on your SDCard).

Until the recent models with significant storage (my current Xperia 10iii and PinePhone Pro both have 128GiB storage), saddly this wasn’t a (good) option: there wasn’t that much storage to expand upon without needing to compromise the home partition.

The usual strategy isn’t straigh mounting /usr/share (that would render the phone unbootable if the card is missing) but just moving a couple of very large directories used by applications to the SD-card and putting symlinks to those back in /usr/share

Yeah, right, overlooked this. Indeed most of the users crazy enough to play with symlinks would know to drop a .nomedia

1 Like

Hi, and sorry for hijacking this thread (didn’t want to make a new one and I’m not soo off topic).

Is there a reason why the file .nomedia gets immediately deleted when creating it in the root directory of sd-card (/run/media/defaultuser/<cardid>/)?

I cded into the directory and first tried
touch .nomedia; ls -a
and then
touch .foo; ls -a; mv .foo .nomeda; ls -a
and even
touch .foo; chmod -w .foo; ls -la; mv .foo .nomedia; ls -a
always ending up with not having .nomedia in it.

It works fine when creating the file in subdirectories.

P.S. SFOS 5.2.0.17 on JP2601, SD card is exFAT formatted

It just disappears?
I cannot reproduce this.
And any other file can be created, hidden or not?
Have you tried creating .nomedia files in subdirectories?
I’m on 5.1.0.11 and the sdcard is formatted ext4. Not that I think it matters.

Can you post grep /run/media /etc/mtab please?
Also ls -al /run/media/defaultuser/*/

Is it possible to run fsck on exFAT filesystems? Worth a try. Unmount it first, then
devel-su fsck -lNMV /run/media/defaultuser/*/

Yes, it disappears immediately after creating it. And only this specific name.

Hint: Before inserting the card, I had already created a .nomedia in its root directory on my PC. After inserting the card into the phone that file persisted a while (maybe for about 5min). When I saw that unwanted picture and audio files where appearing in my media db, I cleaned and restarted localsearch (former tracker). From that moment on, every attempt to recreate .nomedia failed.

I also tried localsearch index --remove /run/media/defaultuser/<cardid> but without success.

Not sure about fsck on exFAT (unfortunately, SFOS lacks man pages).

Running grep /run/media /etc/mtab gives:
/dev/mmcblk0p1 /run/media/defaultuser/3962-3461 exfat rw,nosuid,nodev,relatime,uid=100000,gid=100000,fmask=0022,dmask=0022,iocharset=utf8,errors=remount-ro 0 0

P.S. And yes, creating .nomedia in subdirectories works and behaves as expected – which is now my solution so far.

OK how exactly did you do that?

But the command is installed. And has a --help option. Just try the command I provided above, it’s a test run.

IIRC, .trackerignore is a .nomedia synonym.
Is it also deleted?

It seems to be Android-related.
When AAS is disabled, both .nomedia and .trackerignore persist in SD-card’s root folder.
When AAS is enabled, .nomedia gets deleted after some seconds (and some other empty folders are automatically created), .trackerignore still persists.
The option Show your SailfishOS media in the Android Gallery was always disabled. (Nevertheless, I’d prefer my SD card not being visible at all to Android)

P.S. regarding your questions: I mainly used localsearch reset -s to clean-restart the tracker and then localsearch status to check for completion and whether it indexed too much.

P.P.S. From now on all tests without AAS being enabled:
Both .nomedia and .trackerignore on the card’s root are being ignored by localsearch (it happily traverses the full SD card).
When either .nomedia or .trackerignore reside in a subfolder, localsearch adheres to them (i.e. skips that subtree).

Yeah I tried that yesterday and it did not delete the file either.
Not saying your experience is invalid.

P.S. regarding your questions: I mainly used localsearch reset -s to clean-restart the tracker and then localsearch status to check for completion and whether it indexed too much.

OK nice to know that is an option.

I wonder if that’s some kind of “We are GNOME, that’s how we do things” idiosyncracy.

1 Like

Sounds like it.

I still think this is configurable through the localsearch command and/or dconf keys.

Meaning, tell localsearch to ignore a whole partition.