From 687475cf3cd0654bdd4b6d266561ffa57bc8b676 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 29 Jan 2025 09:40:28 +0100 Subject: [PATCH] db/update/InotifyUpdate: handle IN_CREATE without IN_ISDIR A new symlink causes `IN_CREATE`. Usually, we catch `IN_CREATE` only with IN_ISDIR to watch the new directory, but otherwise `IN_CREATE` is not handled. Regular files are "created" but they have usable content only with `IN_CLOSE_WRITE`. Yet symlinks have only `IN_CREATE` and they are immediately usable. Closes https://github.com/MusicPlayerDaemon/MPD/issues/2192 --- NEWS | 2 ++ src/db/update/InotifyUpdate.cxx | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/NEWS b/NEWS index e14bc2c01..f39025288 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ ver 0.23.17 (not yet released) * storage - nfs: require libnfs 4.0 or later +* database + - inotify: trigger update after symlink was created * support libfmt 11.1 ver 0.23.16 (2024/12/03) diff --git a/src/db/update/InotifyUpdate.cxx b/src/db/update/InotifyUpdate.cxx index 888682df9..40a60c9d0 100644 --- a/src/db/update/InotifyUpdate.cxx +++ b/src/db/update/InotifyUpdate.cxx @@ -293,6 +293,10 @@ InotifyUpdate::InotifyCallback(int wd, unsigned mask, } if ((mask & (IN_CLOSE_WRITE|IN_MOVE|IN_DELETE)) != 0 || + /* regular file or symlink was created; this check is only + interesting for symlinks because regular files have + usable content only after IN_CLOSE_WRITE */ + (mask & (IN_CREATE|IN_ISDIR)) == IN_CREATE || /* at the maximum depth, we watch out for newly created directories */ (directory.GetDepth() == max_depth &&