[Bug]: Chapters are not inited correctly on first import #1564

Closed
opened 2026-02-20 02:03:02 -05:00 by deekerman · 6 comments
Owner

Originally created by @yann-papouin on GitHub (Oct 24, 2023).

Describe the issue

If I add a new audiobook with a lot of files (via samba/network), audiobookshelf detect the new folder and start parsing its content even when the copy is still in progress.

At the end of the copy, if I open the chapter tab, I can see that a lot of chapters are missing:
image

Since audio files are correctly detected, one solution could be to add a callback that would be run to update chapters each time a new audio file is detected and arbitrary this callback should be run only if the diff time between latest_audiofile_n.mtime and latest_audiofile_n-1.mtime is reasonable (~1min ?).

Another solution could be to have an auto_chapter=true attribute on book by default and while chapters have not manually been edited, they are automatically updated by the scanner.

Steps to reproduce the issue

  1. Copy a new big audiobook with a lot of audio files in the library via network (to slow down the copy progress)
  2. Go the the AudioBookShelf Web GUI and see that the scanner just added our new book while the copy is still in progress
  3. At the end of the copy, go to chapters and see that it does not match the count of audio files

Audiobookshelf version

2.4.4

How are you running audiobookshelf?

Docker

Originally created by @yann-papouin on GitHub (Oct 24, 2023). ### Describe the issue If I add a new audiobook with a lot of files (via samba/network), audiobookshelf detect the new folder and start parsing its content even when the copy is still in progress. At the end of the copy, if I open the chapter tab, I can see that a lot of chapters are missing: ![image](https://github.com/advplyr/audiobookshelf/assets/2794099/8f562443-7fa6-4bb2-8910-7226f5fba036) Since audio files are correctly detected, one solution could be to add a callback that would be run to update chapters each time a new audio file is detected and arbitrary this callback should be run only if the diff time between `latest_audiofile_n.mtime` and `latest_audiofile_n-1.mtime` is reasonable (~1min ?). Another solution could be to have an `auto_chapter=true` attribute on `book` by default and while chapters have not manually been edited, they are automatically updated by the scanner. ### Steps to reproduce the issue 1. Copy a new big audiobook with a lot of audio files in the library via network (to slow down the copy progress) 2. Go the the AudioBookShelf Web GUI and see that the scanner just added our new book while the copy is still in progress 3. At the end of the copy, go to chapters and see that it does not match the count of audio files ### Audiobookshelf version 2.4.4 ### How are you running audiobookshelf? Docker
deekerman 2026-02-20 02:03:02 -05:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@nichwall commented on GitHub (Oct 24, 2023):

This is due to the watcher picking up new files before everyone is copied.

https://github.com/advplyr/audiobookshelf/issues/1362

@nichwall commented on GitHub (Oct 24, 2023): This is due to the watcher picking up new files before everyone is copied. https://github.com/advplyr/audiobookshelf/issues/1362
Author
Owner

@advplyr commented on GitHub (Oct 24, 2023):

This is also to do with #2127 because chapters are only set on first scan and are not updated when new files are added.

That will be tricky since we don't have a flag set to tell if a user made manual adjustments to chapters that we shouldn't override

@advplyr commented on GitHub (Oct 24, 2023): This is also to do with #2127 because chapters are only set on first scan and are not updated when new files are added. That will be tricky since we don't have a flag set to tell if a user made manual adjustments to chapters that we shouldn't override
Author
Owner

@Hallo951 commented on GitHub (Oct 25, 2023):

I've noticed that too.

Couldn't one simply implement a watcher that monitors whether the copying process is finished or not? Depending on the result, the watcher is then started with a time delay or after the copying process has finished?

@Hallo951 commented on GitHub (Oct 25, 2023): I've noticed that too. Couldn't one simply implement a watcher that monitors whether the copying process is finished or not? Depending on the result, the watcher is then started with a time delay or after the copying process has finished?
Author
Owner

@advplyr commented on GitHub (Oct 25, 2023):

@Hallo951 This is already implemented but can be improved. The watcher will wait for 4 seconds after a file is added/removed before it starts the scan process. If another file gets added/removed during those 4 seconds the timer is reset.
The issue here has to do with transferring files to a NFS that is very slow.

I have an idea on how to improve this by polling file size but haven't worked on it yet.

@advplyr commented on GitHub (Oct 25, 2023): @Hallo951 This is already implemented but can be improved. The watcher will wait for 4 seconds after a file is added/removed before it starts the scan process. If another file gets added/removed during those 4 seconds the timer is reset. The issue here has to do with transferring files to a NFS that is very slow. I have an idea on how to improve this by polling file size but haven't worked on it yet.
Author
Owner

@advplyr commented on GitHub (Oct 25, 2023):

Duplicate of #1362

@advplyr commented on GitHub (Oct 25, 2023): Duplicate of #1362
Author
Owner

@ghost commented on GitHub (Dec 21, 2024):

@Hallo951 This is already implemented but can be improved. The watcher will wait for 4 seconds after a file is added/removed before it starts the scan process. If another file gets added/removed during those 4 seconds the timer is reset. The issue here has to do with transferring files to a NFS that is very slow.

I have an idea on how to improve this by polling file size but haven't worked on it yet.

I think I just had this problem... I've Uploaded my personal collection with a slow internet connection and now some books have wrong/missing chapters. I've tried a partial / full scan but the only fix for me seems to be manually which is quite the task. I could delete and add the library but would lose my listening status (?). Is there a workaround?

@ghost commented on GitHub (Dec 21, 2024): > @Hallo951 This is already implemented but can be improved. The watcher will wait for 4 seconds after a file is added/removed before it starts the scan process. If another file gets added/removed during those 4 seconds the timer is reset. The issue here has to do with transferring files to a NFS that is very slow. > > I have an idea on how to improve this by polling file size but haven't worked on it yet. I think I just had this problem... I've Uploaded my personal collection with a slow internet connection and now some books have wrong/missing chapters. I've tried a partial / full scan but the only fix for me seems to be manually which is quite the task. I could delete and add the library but would lose my listening status (?). Is there a workaround?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/audiobookshelf#1564
No description provided.