Bug [Scanner]: New Covers Causes Duplicate Books #37

Closed
opened 2026-04-24 22:56:57 +02:00 by adam · 9 comments
Owner

Originally created by @Budlyte on GitHub (Oct 1, 2021).

I added covers to some books that were missing them and it created duplicate books.

image

image

Originally created by @Budlyte on GitHub (Oct 1, 2021). I added covers to some books that were missing them and it created duplicate books. ![image](https://user-images.githubusercontent.com/4451365/135548674-56f07243-9e2e-4450-b60d-f1cc320f128b.png) ![image](https://user-images.githubusercontent.com/4451365/135548862-1dd7d268-8b4c-4161-adf5-4364e54cb542.png)
adam closed this issue 2026-04-24 22:56:57 +02:00
Author
Owner

@advplyr commented on GitHub (Oct 1, 2021):

Did you upload the covers or drag them into the folder?
Are you using v1.3.1?

@advplyr commented on GitHub (Oct 1, 2021): Did you upload the covers or drag them into the folder? Are you using `v1.3.1`?
Author
Owner

@Budlyte commented on GitHub (Oct 1, 2021):

Yeah, v1.3.1

I saved them to the folders and the scanner re-ran. But, I just noticed, those aren't the covers I saved in there. The new files are square images. ??

image

@Budlyte commented on GitHub (Oct 1, 2021): Yeah, v1.3.1 I saved them to the folders and the scanner re-ran. But, I just noticed, those aren't the covers I saved in there. The new files are square images. ?? ![image](https://user-images.githubusercontent.com/4451365/135550066-9c4185b0-0c68-4f48-b97e-ea4b51dc30b7.png)
Author
Owner

@advplyr commented on GitHub (Oct 1, 2021):

The new version uses the cover embedded in the audio file if there is one.
If there is a cover already set it won't override it though and you should still see the covers listed under "local covers" in the edit covers page.

If you delete those duplicates and press scan again, does it create more duplicates?

@advplyr commented on GitHub (Oct 1, 2021): The new version uses the cover embedded in the audio file if there is one. If there is a cover already set it won't override it though and you should still see the covers listed under "local covers" in the edit covers page. If you delete those duplicates and press scan again, does it create more duplicates?
Author
Owner

@advplyr commented on GitHub (Oct 1, 2021):

Duplicate audiobooks must be an issue with the inode value again, which has me stumped.

If you open a terminal and run stat "{audiobook folder name}" you can see the Inode value of the folder.

Here is what it looks like on my machine:

image

@advplyr commented on GitHub (Oct 1, 2021): Duplicate audiobooks must be an issue with the inode value again, which has me stumped. If you open a terminal and run `stat "{audiobook folder name}"` you can see the Inode value of the folder. Here is what it looks like on my machine: ![image](https://user-images.githubusercontent.com/67830747/135550971-9ef4b93a-a790-4766-8180-149806e55963.png)
Author
Owner

@Budlyte commented on GitHub (Oct 1, 2021):

Oh, well that's a really good update. A library scan on startup might have prevented this.

Hmm, so when I did a full rescan it marked the old books that I had placed covers in as "missing".
image

But any new ones that scanned in from the audio file came in fine. See No.5 here. Number 2 threw an error too because I added a cover to its folder after posting the image above.
image

Stats on Reckoners

root@Tower:/mnt/user/Audio/Audiobooks/Brandon Sanderson# stat "Reckoners"
  File: Reckoners
  Size: 83              Blocks: 0          IO Block: 4096   directory
Device: 31h/49d Inode: 216454257091916610  Links: 1
Access: (0775/drwxrwxr-x)  Uid: (   99/  nobody)   Gid: (  100/   users)
Access: 2021-09-19 08:31:52.235019282 -0500
Modify: 2021-09-19 08:32:00.484125416 -0500
Change: 2021-09-30 20:03:45.457346525 -0500
 Birth: -

*** Whoa, that scan added so many covers!

@Budlyte commented on GitHub (Oct 1, 2021): Oh, well that's a really good update. A library scan on startup might have prevented this. Hmm, so when I did a full rescan it marked the old books that I had placed covers in as "missing". ![image](https://user-images.githubusercontent.com/4451365/135551256-cc9df19d-c7f5-4ae0-9c41-b02e966a0f0e.png) But any new ones that scanned in from the audio file came in fine. See No.5 here. Number 2 threw an error too because I added a cover to its folder after posting the image above. ![image](https://user-images.githubusercontent.com/4451365/135551333-d32cf6a6-20af-40cf-a068-ad9a8e47063d.png) Stats on Reckoners ``` root@Tower:/mnt/user/Audio/Audiobooks/Brandon Sanderson# stat "Reckoners" File: Reckoners Size: 83 Blocks: 0 IO Block: 4096 directory Device: 31h/49d Inode: 216454257091916610 Links: 1 Access: (0775/drwxrwxr-x) Uid: ( 99/ nobody) Gid: ( 100/ users) Access: 2021-09-19 08:31:52.235019282 -0500 Modify: 2021-09-19 08:32:00.484125416 -0500 Change: 2021-09-30 20:03:45.457346525 -0500 Birth: - ``` *** Whoa, that scan added so many covers!
Author
Owner

@Budlyte commented on GitHub (Oct 1, 2021):

I was mistaken, several others created duplicates as well and invalidated the previous book.

What I can't tell is if everything that got invalidated was a book that had a cover file, or what the connection is. There are plenty that got their covers extracted though and are fine now.

Honestly, this might not be a real issue, it might just be growing pains as the system updates to a collection that exists (the cause). New users may never see this issue and deleting the invalidated books seems to have cleared up the symptom.

ugh, things are scanning slowly tonight. I had a drive throw a bad sector so it's going through an extended SMART test and the parity drive is running everything. Doing all this while that goes on is probably a bad idea. D:

@Budlyte commented on GitHub (Oct 1, 2021): I was mistaken, several others created duplicates as well and invalidated the previous book. What I can't tell is if everything that got invalidated was a book that had a cover file, or what the connection is. There are plenty that got their covers extracted though and are fine now. Honestly, this might not be a real issue, it might just be growing pains as the system updates to a collection that exists (the cause). New users may never see this issue and deleting the invalidated books seems to have cleared up the symptom. ugh, things are scanning slowly tonight. I had a drive throw a bad sector so it's going through an extended SMART test and the parity drive is running everything. Doing all this while that goes on is probably a bad idea. D:
Author
Owner

@Budlyte commented on GitHub (Oct 1, 2021):

Ok, I found a way to reproduce what's happening to the inode value, using the "Save Metadata" button causes a duplicate book to show up.

Here's the before & after hitting the button.

root@Tower:/mnt/user/Audio/Audiobooks/Brent Weeks/Lightbringer (2010)# stat "Lightbringer - Book 1 - The Black Prism"
  File: Lightbringer - Book 1 - The Black Prism
  Size: 65              Blocks: 0          IO Block: 4096   directory
Device: 31h/49d Inode: 648799821318078724  Links: 1
Access: (0775/drwxrwxr-x)  Uid: (   99/  nobody)   Gid: (  100/   users)
Access: 2021-07-23 15:38:23.000000000 -0500
Modify: 2021-09-19 00:50:30.666807519 -0500
Change: 2021-09-25 12:16:07.998064359 -0500
 Birth: -
root@Tower:/mnt/user/Audio/Audiobooks/Brent Weeks/Lightbringer (2010)# stat "Lightbringer - Book 1 - The Black Prism"
  File: Lightbringer - Book 1 - The Black Prism
  Size: 26              Blocks: 0          IO Block: 4096   directory
Device: 31h/49d Inode: 216454257092072568  Links: 1
Access: (0775/drwxrwxr-x)  Uid: (   99/  nobody)   Gid: (  100/   users)
Access: 2021-07-23 15:38:23.000000000 -0500
Modify: 2021-09-30 21:29:43.970786850 -0500
Change: 2021-09-30 21:29:43.970786850 -0500
 Birth: -
@Budlyte commented on GitHub (Oct 1, 2021): Ok, I found a way to reproduce what's happening to the inode value, using the "Save Metadata" button causes a duplicate book to show up. Here's the before & after hitting the button. ``` root@Tower:/mnt/user/Audio/Audiobooks/Brent Weeks/Lightbringer (2010)# stat "Lightbringer - Book 1 - The Black Prism" File: Lightbringer - Book 1 - The Black Prism Size: 65 Blocks: 0 IO Block: 4096 directory Device: 31h/49d Inode: 648799821318078724 Links: 1 Access: (0775/drwxrwxr-x) Uid: ( 99/ nobody) Gid: ( 100/ users) Access: 2021-07-23 15:38:23.000000000 -0500 Modify: 2021-09-19 00:50:30.666807519 -0500 Change: 2021-09-25 12:16:07.998064359 -0500 Birth: - root@Tower:/mnt/user/Audio/Audiobooks/Brent Weeks/Lightbringer (2010)# stat "Lightbringer - Book 1 - The Black Prism" File: Lightbringer - Book 1 - The Black Prism Size: 26 Blocks: 0 IO Block: 4096 directory Device: 31h/49d Inode: 216454257092072568 Links: 1 Access: (0775/drwxrwxr-x) Uid: ( 99/ nobody) Gid: ( 100/ users) Access: 2021-07-23 15:38:23.000000000 -0500 Modify: 2021-09-30 21:29:43.970786850 -0500 Change: 2021-09-30 21:29:43.970786850 -0500 Birth: - ```
Author
Owner

@advplyr commented on GitHub (Oct 1, 2021):

I found why this is happening.
In Unraid the files may be split between two disks, which means the folder might exist multiple times.

For example I had that audiobook on 2 disks.
/mnt/disk2/media/Audiobooks/Adam Smith/The Wealth of Nations/
and
/mnt/disk4/media/Audiobooks/Adam Smith/The Wealth of Nations/

I moved all the audiobook files inside the one on disk4 into the one on disk2 and deleted the empty folder on disk4.
Running stat "/mnt/user/media/Audiobooks/Adam Smith/The Wealth of Nations/" resulted in a different inode value.

This makes sense actually, it is unfortunate since now I have to think of a new way to track folders, but at least the problem has been identified.

@advplyr commented on GitHub (Oct 1, 2021): I found why this is happening. In Unraid the files may be split between two disks, which means the folder might exist multiple times. For example I had that audiobook on 2 disks. `/mnt/disk2/media/Audiobooks/Adam Smith/The Wealth of Nations/` and `/mnt/disk4/media/Audiobooks/Adam Smith/The Wealth of Nations/` I moved all the audiobook files inside the one on disk4 into the one on disk2 and deleted the empty folder on disk4. Running `stat "/mnt/user/media/Audiobooks/Adam Smith/The Wealth of Nations/"` resulted in a different inode value. This makes sense actually, it is unfortunate since now I have to think of a new way to track folders, but at least the problem has been identified.
Author
Owner

@advplyr commented on GitHub (Oct 2, 2021):

I implemented a solution for release v1.3.3

For posterity..

This issue will only occur on shared drives, where files might move between file systems. The following only applies to shared file systems (i.e. Unraid).

Background

Saving the inode value for the audiobook directory and files is necessary to handle renames, so a renamed folder/file can be matched with the existing audiobook. The inode value should not change on renames, it will only change when adding/removing files.

Solution

When scanning, first match audiobooks and files by their inode (catches renames), then fallback to using the filepath. When an audiobook directory gets scanned, all inode values will be updated.

@advplyr commented on GitHub (Oct 2, 2021): I implemented a solution for release [v1.3.3](https://github.com/advplyr/audiobookshelf/releases/tag/v1.3.3) For posterity.. This issue will only occur on shared drives, where files might move between file systems. The following only applies to shared file systems (i.e. Unraid). #### Background Saving the inode value for the audiobook directory and files is necessary to handle renames, so a renamed folder/file can be matched with the existing audiobook. The inode value should not change on renames, it will only change when adding/removing files. #### Solution When scanning, first match audiobooks and files by their inode (catches renames), then fallback to using the filepath. When an audiobook directory gets scanned, all inode values will be updated.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#37