Mopidy always looses all local tracks if HDD is not present

Hey,
My usecase is as follows:
I’m using mopidy on my Pi with the musicbox_webclient and have a external HDD attached. The HDD get’s automounted when accessed. Normally I turn off the HDD when I’m not using it.
The problem is that then mopidy doesn’t find any local tracks and I have always to do a local scan before I can listen to my music.
So my question is: is there a way to preserve the local library? Or does someone has an idea how to stop mopidy from this behaviour?
Greetings,
Zaph

You must scan your local files for them to be added to the local library. Once you do this they will remain in the local library until you scan again. The library data is stored in the folder you specify (see the docs). If you rescan whilst the drive is unavailable (switched off, not mounted, whatever) the now missing tracks will be removed from the local library. This behaviour can be seen in the log output.

Please post your config and a log file else it’s hard to understand what exactly you are doing here.

Hey thanks for your answer.
It clearified a few things for me. Since I point mediadir to the external HDD, the json file can’t be loaded by mopidy if the HDD is turned off.
I’m now using the local sqlite extension for my library. With this I don’t need to rescan after I turned the HDD off and on again.
Still not sure if the behaviour is normal, since after I turn the HDD on and mount it, mopidy should find the local json file, right?

EDIT: and to clearify: I never rescanned while the HDD is unmounted.

When you restart Mopidy. Are you running Mopidy as a service?

I’m running it as a service. So you mean I should have restarted mopidy with every remount of the HDD?

I guess so. You can’t expect Mopidy to constantly monitor when it’s library database (file) is becoming available. It’s just like making changes to the config file, that also requires a restart.