[PR #1287] [MERGED] Fix Sub-path Detection #3504

Closed
opened 2026-04-25 00:15:55 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/1287
Author: @lkiesow
Created: 12/18/2022
Status: Merged
Merged: 12/18/2022
Merged by: @advplyr

Base: masterHead: subpath-detection


📝 Commits (1)

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 server/scanner/Scanner.js (+1 -1)

📄 Description

If the scanner detects new files with a path containing part of the name of an already existing library item, the new item will incorrectly be detected as being a parent directory of the already existing item and the import will be aborted.

You can follow these steps to reproduce the issue:

❯ mkdir audiobooks/author/

❯ mv title\ 10 audiobooks/author
[2022-12-18 22:14:12] DEBUG: [Watcher] File Added /home/lars/dev/audiobookshelf/audiobooks/author/title 10/dictaphone.mp3
[2022-12-18 22:14:16] DEBUG: [DB] Library Items inserted 1

❯ mv title\ 1 audiobooks/author
[2022-12-18 22:15:03] DEBUG: [Watcher] File Added /home/lars/dev/audiobookshelf/audiobooks/author/title 1/dictaphone.mp3
[2022-12-18 22:15:07]  WARN: [Scanner] Files were modified in a parent directory of a library item "title 10" - ignoring

Since 'title 10'.startsWith('title 1') is true, the current code makes this false assumption.

This patch fixes the issue by requiring a path separator to be part of the matching path. This should ensure that only true parent directories are detected.

This patch requires audiobookshelf to always use Unix file separators. But that shouldn't be a problem since audiobookshelf always seems to use these kinds of separators. Even on Windows.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf/pull/1287 **Author:** [@lkiesow](https://github.com/lkiesow) **Created:** 12/18/2022 **Status:** ✅ Merged **Merged:** 12/18/2022 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `subpath-detection` --- ### 📝 Commits (1) - [`90299e3`](https://github.com/advplyr/audiobookshelf/commit/90299e348cf3404b4391471a210eb0730b354d90) Fix Sub-path Detection ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `server/scanner/Scanner.js` (+1 -1) </details> ### 📄 Description If the scanner detects new files with a path containing part of the name of an already existing library item, the new item will incorrectly be detected as being a parent directory of the already existing item and the import will be aborted. You can follow these steps to reproduce the issue: ``` ❯ mkdir audiobooks/author/ ❯ mv title\ 10 audiobooks/author [2022-12-18 22:14:12] DEBUG: [Watcher] File Added /home/lars/dev/audiobookshelf/audiobooks/author/title 10/dictaphone.mp3 [2022-12-18 22:14:16] DEBUG: [DB] Library Items inserted 1 ❯ mv title\ 1 audiobooks/author [2022-12-18 22:15:03] DEBUG: [Watcher] File Added /home/lars/dev/audiobookshelf/audiobooks/author/title 1/dictaphone.mp3 [2022-12-18 22:15:07] WARN: [Scanner] Files were modified in a parent directory of a library item "title 10" - ignoring ``` Since `'title 10'.startsWith('title 1')` is `true`, the current code makes this false assumption. This patch fixes the issue by requiring a path separator to be part of the matching path. This should ensure that only true parent directories are detected. This patch requires audiobookshelf to always use Unix file separators. But that shouldn't be a problem since audiobookshelf always seems to use these kinds of separators. Even on Windows. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:15:55 +02:00
adam closed this issue 2026-04-25 00:15:55 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#3504