Fix inotifywait.sh: run:updateCatalogFile invalid flag syntax silently breaks auto-catalog-sync#139
Open
godmarck wants to merge 1 commit into
Open
Conversation
inotifywait.sh calls run:updateCatalogFile with -n/-f flags, but that command takes <catalogName> and <filePath> as positional arguments, not flag options. As a result, every file-change event caught by the directory monitor fails to parse and just prints the command's usage text instead of actually updating the catalog - so newly added, moved, or renamed files are silently never indexed. This also fixes a malformed `[["$VAR" == "1"]]` test (missing spaces around `[[`/`]]`) in the DISABLE_INOTIFYWAIT_CLEAN branch, which was always evaluating as a failed command rather than a real conditional. The catalog name is now read from a new CATALOG_NAME env var (defaulting to "music" to preserve existing behavior) instead of being hardcoded, since it must match an actual catalog name. Verified locally: before the fix, every detected file change printed the run:updateCatalogFile help/usage text to the container logs instead of updating anything. After the fix, changed files are correctly added/cleaned/verified in the catalog.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
data/bin/inotifywait.shwatches/mediaand, on every detected file change, runs:php /var/www/bin/cli run:updateCatalogFile -n music -f "$file" -cageBut
run:updateCatalogFiletakes the catalog name and file path as positional arguments, not-n/-fflags:Because of this mismatch, the command fails to parse its arguments and just prints its own help/usage text instead of running — every single time, for every file. The net effect is that automatic catalog updates on file add/move/rename never actually happen, silently. There's no error, just usage text buried in a log nobody watches. Users only notice indirectly, e.g. newly added folders/artists returning "not found" when browsing in a Subsonic-API client.
There's also a syntax bug in the
DISABLE_INOTIFYWAIT_CLEANconditional —[["$DISABLE_INOTIFYWAIT_CLEAN" == "1"]]is missing the required spaces around[[/]], so bash treats[["$DISABLE_INOTIFYWAIT_CLEAN"as an (nonexistent) command rather than a test expression. It always falls through to theelsebranch regardless of the env var's value.Fix
run:updateCatalogFilewith the catalog name and file path as positional arguments, and pass-a -c -e -g/-a -e -gas separate option flags.[[ ... ]]spacing so theDISABLE_INOTIFYWAIT_CLEANcheck actually works."music", which only works if a catalog happens to be named exactly that. Pulled it out into aCATALOG_NAMEenv var (defaultmusic, so existing setups relying on the default behavior see no change), documented in the README alongside the other env vars.Verification
Reproduced against a live
ampache/ampache:latestcontainer (Ampache 7.9.8): before the fix, everyclose_write/create/moved_to/deleteevent under/medialogged the file path followed byrun:updateCatalogFile's usage/help dump. After deploying the corrected script and restarting the watcher, the same events correctly invokerun:updateCatalogFile <catalog> <path> -a -c -e -gand the file is added/verified in the catalog (confirmed via direct DB query and by triggering a real file event).