audiobookshelf/server
Lars Kiesow 90299e348c
Fix Sub-path Detection
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.
2022-12-18 22:23:50 +01:00
..
controllers Add:Manage genres #1163 2022-12-18 14:52:53 -06:00
finders Add:Region support for audible chapter lookup 2022-10-15 15:31:07 -05:00
libs Update server/libs/nodeFfprobe/index.js 2022-09-24 17:36:29 -05:00
managers Fix:Setting file ownership for /config and /metadata/logs #584 2022-12-15 17:30:45 -06:00
objects Add:Create playlist from a collection #1226 2022-12-17 17:31:19 -06:00
providers Use HTTPS for Google Books Images 2022-12-18 00:18:11 +01:00
routers Add:Manage genres #1163 2022-12-18 14:52:53 -06:00
scanner Fix Sub-path Detection 2022-12-18 22:23:50 +01:00
utils Add:Book library filter for missing cover image #1243 2022-12-15 17:46:27 -06:00
Auth.js Update:Only emit library socket events to users with access to lib 2022-11-30 17:32:59 -06:00
Db.js Add:Item metadata utils config page for managing tags #1163 2022-12-18 14:17:52 -06:00
Logger.js Remove dependency date-and-time 2022-07-06 19:18:27 -05:00
Server.js Add:Item metadata utils config page for managing tags #1163 2022-12-18 14:17:52 -06:00
SocketAuthority.js Update:Only emit library socket events to users with access to lib 2022-11-30 17:32:59 -06:00
Watcher.js Fix:Include Watcher as lib with no dependencies and fix tiny-readdir bug #610 2022-05-28 20:01:20 -05:00