From aaf2eb436c34ccd530a968409d45fe9d2ea5ce19 Mon Sep 17 00:00:00 2001 From: Hannes Hauswedell Date: Wed, 29 Jul 2026 18:18:28 +0200 Subject: [PATCH] fix(#2015): store correct path of symlinks --- src/library/filescanner.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/library/filescanner.c b/src/library/filescanner.c index de3169a563..6e55d733e4 100644 --- a/src/library/filescanner.c +++ b/src/library/filescanner.c @@ -911,7 +911,14 @@ process_directory(char *path, int parent_id, int flags) else if (!(flags & F_SCAN_FAST)) { if (S_ISREG(sb.st_mode) || S_ISFIFO(sb.st_mode)) - process_file(resolved_path, &sb, file_type, scan_type, flags, dir_id); + /* Use the path we found the file at, not the dereferenced path. For + * regular files the two are identical, but for symlinks it means the + * file is registered where the user put it, ie below the directory + * we are scanning. Otherwise the file's directory_id and its path + * would disagree, and lookups by path (eg mpd's "add") would not + * find it, even though browsing the directory would show it. + */ + process_file(entry, &sb, file_type, scan_type, flags, dir_id); else DPRINTF(E_LOG, L_SCAN, "Skipping %s, not a directory, symlink, pipe nor regular file\n", entry); }