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
This commit is contained in:
Max Kellermann
2025-01-29 09:40:28 +01:00
parent c48dbd5dd4
commit 687475cf3c
2 changed files with 6 additions and 0 deletions

2
NEWS
View File

@@ -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)

View File

@@ -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 &&