minidlna comes with a "rescan" command for rc.d. However, this reads rescan_cmd="$command -R -u $minidlna_uid -f /usr/local/etc/minidlna.conf" This is in line with the manpage, but obviously wrong when comparing to the commandline help (minidlnad -h): -r forces a rescan -R forces a rebuild So "-R" forces a rebuild of the database while a rescan uses "-r". I verified that this is what is actually happening by checking the database file and the time each command takes (rescan is fast and just adds new stuff, rebuild takes much longer and also removed outdated entries). Thus I propose to change the rc.d script to contain extra_commands="rescan rebuild" rescan_cmd="$command -r -u $minidlna_uid -f /usr/local/etc/minidlna.conf" rebuild_cmd="$command -R -u $minidlna_uid -f /usr/local/etc/minidlna.conf" Furthermore, as this is not handled via signals on the running process, it might be useful to force a stop command before doing either rescan or rebuild.
Created attachment 229687 [details] Proposed patch to rectify rescan/rebuild commands Add proposed patch (so far without forcing stop).
Comment on attachment 229687 [details] Proposed patch to rectify rescan/rebuild commands >--- minidlna.in~ 2021-11-24 08:46:30.000000000 +0100 >+++ minidlna.in 2021-11-24 08:47:17.757510000 +0100 >@@ -27,7 +27,8 @@ > start_precmd="install -d -o $minidlna_uid ${pidfile%/*} /var/db/minidlna" > stop_postcmd="rm -f $pidfile" > >-extra_commands=rescan >+extra_commands="rescan rebuild" >+rescan_cmd="$command -r -u $minidlna_uid -f %%PREFIX%%/etc/minidlna.conf" > rescan_cmd="$command -R -u $minidlna_uid -f %%PREFIX%%/etc/minidlna.conf" > > run_rc_command $1
Created attachment 229688 [details] patch with correct PREFIX path added Sorry for messing up the patch creation before, hopefully this will work now. ;-)
For the record: There is an open request for minidlna to support signal for rescan unter https://sourceforge.net/p/minidlna/patches/172/ However, it looks like this hasn't made it into any release, yet.
The patch doesn't seem correct to me. Patched file would have to assignments to $rescan_cmd. Also, here is what -R does inside minidlnad: case 'R': snprintf(buf, sizeof(buf), "rm -rf %s/files.db %s/art_cache", db_path, db_path); if (system(buf) != 0) DPRINTF(E_FATAL, L_GENERAL, "Failed to clean old file cache %s. EXITING\n", db_path); break; And that's all :( I also looked at the pull request. Looks like more work needs to be done on the side of the minidlna itself. Not much we can do in our port.
In the last message: s/to assignments/two assignments/.
(In reply to Gleb Smirnoff from comment #6) Yeah, and I managed to mess up the suggested patch twice. :-( Aynway: extra_commands="rescan rebuild" rescan_cmd="$command -r -u $minidlna_uid -f /usr/local/etc/minidlna.conf" rebuild_cmd="$command -R -u $minidlna_uid -f /usr/local/etc/minidlna.conf" All I can say is that this works for me as advertised in the commandline help. This is useful for me as rescanning the database is more lightweight than rebuilding. From the code: case 'r': SETFLAG(RESCAN_MASK); break;
What if I just substitute -R with -r in the existing script, without adding any extra commands? What minidlna does with -R seems too stupid for me to officially offer our users :)
(In reply to Gleb Smirnoff from comment #8) Well, if the user really wants to rebuild the database, what is he supposed to do? Either find out where the database files live and delete them manually, or stop, minidlna service and call it with the -R option manually on the commandline. So yeah, substituting -R with -r in the existing script is certainly better than doing nothing, but simply adding the option won't hurt anyone and would imho show more consist behaviour to the user.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=c56f2a7ef8c8ce8d11277f12343fd2dee1358ec9 commit c56f2a7ef8c8ce8d11277f12343fd2dee1358ec9 Author: Gleb Smirnoff <glebius@FreeBSD.org> AuthorDate: 2024-12-29 21:42:09 +0000 Commit: Gleb Smirnoff <glebius@FreeBSD.org> CommitDate: 2024-12-29 21:42:09 +0000 net/minidlna: rescan/rebuild support in rc script Fix the rescan command to actually send rescan signal to minidlnad, instead of doing a rebuild. Add rebuild command. Submitted by: gerrit@weinberg2.de PR: 259953 net/minidlna/Makefile | 2 +- net/minidlna/files/minidlna.in | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-)