Skip to content

Fix inotifywait.sh: run:updateCatalogFile invalid flag syntax silently breaks auto-catalog-sync#139

Open
godmarck wants to merge 1 commit into
ampache:masterfrom
godmarck:fix/inotifywait-updatecatalogfile-syntax
Open

Fix inotifywait.sh: run:updateCatalogFile invalid flag syntax silently breaks auto-catalog-sync#139
godmarck wants to merge 1 commit into
ampache:masterfrom
godmarck:fix/inotifywait-updatecatalogfile-syntax

Conversation

@godmarck

Copy link
Copy Markdown

Problem

data/bin/inotifywait.sh watches /media and, on every detected file change, runs:

php /var/www/bin/cli run:updateCatalogFile -n music -f "$file" -cage

But run:updateCatalogFile takes the catalog name and file path as positional arguments, not -n/-f flags:

Usage: run:updateCatalogFile [OPTIONS...] [ARGUMENTS...]
Arguments:
  <catalogName>    Catalog Name
  <filePath>       File Path

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_CLEAN conditional — [["$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 the else branch regardless of the env var's value.

Fix

  • Call run:updateCatalogFile with the catalog name and file path as positional arguments, and pass -a -c -e -g / -a -e -g as separate option flags.
  • Fix the [[ ... ]] spacing so the DISABLE_INOTIFYWAIT_CLEAN check actually works.
  • The catalog name was hardcoded to "music", which only works if a catalog happens to be named exactly that. Pulled it out into a CATALOG_NAME env var (default music, 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:latest container (Ampache 7.9.8): before the fix, every close_write/create/moved_to/delete event under /media logged the file path followed by run:updateCatalogFile's usage/help dump. After deploying the corrected script and restarting the watcher, the same events correctly invoke run:updateCatalogFile <catalog> <path> -a -c -e -g and the file is added/verified in the catalog (confirmed via direct DB query and by triggering a real file event).

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant