[Bug]: Weekly Library Scan does not honor Metadata order of Precedence #1824

Closed
opened 2026-02-20 10:13:03 -05:00 by deekerman · 1 comment
Owner

Originally created by @bwprog on GitHub (Mar 18, 2024).

Describe the issue

Audiobookshelf metadata file is the #1 precedence (default order). I make changes to books like correcting author names (e.g. 'J. R. R. Tolkein' to 'J.R.R. Tolkein' to merge into single author) or fixing series names. The weekly scan happens which ignores the precedence order and overwrites the library changes with what is in the audiobook m4b metadata. This happens whether the metadata json file is stored with the books or not--I've tried both methods.

The scan log shows this as the order.
{"timestamp":"2024-03-18T07:06:34.126Z","message":""Honor Among Enemies" Getting metadata with precedence [folderStructure, audioMetatags, nfoFile, txtFiles, opfFile, absMetadata]","levelName":"DEBUG","level":1}

Example from log showing the author reverting.
"timestamp":"2024-03-18T07:13:01.930Z","message":"Library item "J.N. Chaney/Renegade Origins/01 - Nameless" key "ctime" changed from "1709496949448" to "1710620503636"","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-18T07:13:01.930Z","message":"Library file "Nameless A Renegade Star Story Renegade Star, Book 0.m4b" for library item "/audiobooks/J.N. Chaney/Renegade Origins/01 - Nameless" key "ctimeMs" changed from "1708368842108" to "1710620503636"","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-18T07:13:01.931Z","message":"Library file "Nameless A Renegade Star Story Renegade Star, Book 0.jpg" for library item "/audiobooks/J.N. Chaney/Renegade Origins/01 - Nameless" key "ctimeMs" changed from "1708368842108" to "1710620503636"","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-18T07:13:01.931Z","message":"Library file "cover.jpg" for library item "/audiobooks/J.N. Chaney/Renegade Origins/01 - Nameless" key "ctimeMs" changed from "1709496949448" to "1710620503636"","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-18T07:13:01.931Z","message":"Library item "J.N. Chaney/Renegade Origins/01 - Nameless" changed: [ctime,size,lastScan,lastScanVersion]","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-18T07:13:02.072Z","message":""Nameless" Getting metadata with precedence [folderStructure, audioMetatags, nfoFile, txtFiles, opfFile, absMetadata]","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-18T07:13:02.072Z","message":"setChapters: Using embedded chapters in first audio file /audiobooks/J.N. Chaney/Renegade Origins/01 - Nameless/Nameless A Renegade Star Story Renegade Star, Book 0.m4b","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-18T07:13:02.072Z","message":"Found metadata file "/metadata/items/1633d10f-837c-496e-ac2b-da990c9bbcc2/metadata.json"","levelName":"INFO","level":2}
{"timestamp":"2024-03-18T07:13:02.113Z","message":"Updating book "Nameless: A Renegade Star Story" added author "J. N. Chaney"","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-18T07:13:02.116Z","message":"Updating book "Nameless: A Renegade Star Story" removed author "J.N. Chaney"","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-18T07:13:02.120Z","message":"Success saving abmetadata to "/audiobooks/J.N. Chaney/Renegade Origins/01 - Nameless/metadata.json"","levelName":"DEBUG","level":1}

The only way I have found to prevent this is to uncheck the other metadata options which then shows only the 2 still enabled in the log. Still the wrong order, but without the audioMetatags it doesn't mess up the library.
{"timestamp":"2024-03-04T15:41:25.236Z","message":""Servant of the Dragon" Getting metadata with precedence [folderStructure, absMetadata]","levelName":"DEBUG","level":1}

The issue was in 2.7.2 and 2.8.0. I used the workaround in 2.8.0. The upgrade to 2.8.1 seemed to re-enable the other 4 metadata options, so last night's weekly scan overwrote all my manual library changes again.

Steps to reproduce the issue

  1. Edit a book's metadata to change something like author name or series name (if the m4b has a series name already).
  2. Set Scanner order of precedence to default with absMetadata at number 1 and don't disable any others.
  3. Wait for the scheduled scan to run. Note that manually running the scan may not revert the change, but the weekly scheduled scan always does. The manual scan log does state it is updating the book but doesn't state it is changing author the way the weekly does.
  4. Once scan complete, see the book metadata changes were reverted.
  5. See the wrong precedence order shown in the log file.

Audiobookshelf version

v2.8.1

How are you running audiobookshelf?

Docker

Originally created by @bwprog on GitHub (Mar 18, 2024). ### Describe the issue Audiobookshelf metadata file is the #1 precedence (default order). I make changes to books like correcting author names (e.g. 'J. R. R. Tolkein' to 'J.R.R. Tolkein' to merge into single author) or fixing series names. The weekly scan happens which ignores the precedence order and overwrites the library changes with what is in the audiobook m4b metadata. This happens whether the metadata json file is stored with the books or not--I've tried both methods. The scan log shows this as the order. {"timestamp":"2024-03-18T07:06:34.126Z","message":"\"Honor Among Enemies\" Getting metadata with precedence [folderStructure, audioMetatags, nfoFile, txtFiles, opfFile, absMetadata]","levelName":"DEBUG","level":1} Example from log showing the author reverting. "timestamp":"2024-03-18T07:13:01.930Z","message":"Library item \"J.N. Chaney/Renegade Origins/01 - Nameless\" key \"ctime\" changed from \"1709496949448\" to \"1710620503636\"","levelName":"DEBUG","level":1} {"timestamp":"2024-03-18T07:13:01.930Z","message":"Library file \"Nameless A Renegade Star Story Renegade Star, Book 0.m4b\" for library item \"/audiobooks/J.N. Chaney/Renegade Origins/01 - Nameless\" key \"ctimeMs\" changed from \"1708368842108\" to \"1710620503636\"","levelName":"DEBUG","level":1} {"timestamp":"2024-03-18T07:13:01.931Z","message":"Library file \"Nameless A Renegade Star Story Renegade Star, Book 0.jpg\" for library item \"/audiobooks/J.N. Chaney/Renegade Origins/01 - Nameless\" key \"ctimeMs\" changed from \"1708368842108\" to \"1710620503636\"","levelName":"DEBUG","level":1} {"timestamp":"2024-03-18T07:13:01.931Z","message":"Library file \"cover.jpg\" for library item \"/audiobooks/J.N. Chaney/Renegade Origins/01 - Nameless\" key \"ctimeMs\" changed from \"1709496949448\" to \"1710620503636\"","levelName":"DEBUG","level":1} {"timestamp":"2024-03-18T07:13:01.931Z","message":"Library item \"J.N. Chaney/Renegade Origins/01 - Nameless\" changed: [ctime,size,lastScan,lastScanVersion]","levelName":"DEBUG","level":1} {"timestamp":"2024-03-18T07:13:02.072Z","message":"\"Nameless\" Getting metadata with precedence [folderStructure, audioMetatags, nfoFile, txtFiles, opfFile, absMetadata]","levelName":"DEBUG","level":1} {"timestamp":"2024-03-18T07:13:02.072Z","message":"setChapters: Using embedded chapters in first audio file /audiobooks/J.N. Chaney/Renegade Origins/01 - Nameless/Nameless A Renegade Star Story Renegade Star, Book 0.m4b","levelName":"DEBUG","level":1} {"timestamp":"2024-03-18T07:13:02.072Z","message":"Found metadata file \"/metadata/items/1633d10f-837c-496e-ac2b-da990c9bbcc2/metadata.json\"","levelName":"INFO","level":2} {"timestamp":"2024-03-18T07:13:02.113Z","message":"Updating book \"Nameless: A Renegade Star Story\" added author \"J. N. Chaney\"","levelName":"DEBUG","level":1} {"timestamp":"2024-03-18T07:13:02.116Z","message":"Updating book \"Nameless: A Renegade Star Story\" removed author \"J.N. Chaney\"","levelName":"DEBUG","level":1} {"timestamp":"2024-03-18T07:13:02.120Z","message":"Success saving abmetadata to \"/audiobooks/J.N. Chaney/Renegade Origins/01 - Nameless/metadata.json\"","levelName":"DEBUG","level":1} The only way I have found to prevent this is to uncheck the other metadata options which then shows only the 2 still enabled in the log. Still the wrong order, but without the audioMetatags it doesn't mess up the library. {"timestamp":"2024-03-04T15:41:25.236Z","message":"\"Servant of the Dragon\" Getting metadata with precedence [folderStructure, absMetadata]","levelName":"DEBUG","level":1} The issue was in 2.7.2 and 2.8.0. I used the workaround in 2.8.0. The upgrade to 2.8.1 seemed to re-enable the other 4 metadata options, so last night's weekly scan overwrote all my manual library changes again. ### Steps to reproduce the issue 1. Edit a book's metadata to change something like author name or series name (if the m4b has a series name already). 2. Set Scanner order of precedence to default with absMetadata at number 1 and don't disable any others. 3. Wait for the scheduled scan to run. Note that manually running the scan may not revert the change, but the weekly scheduled scan always does. The manual scan log does state it is updating the book but doesn't state it is changing author the way the weekly does. 4. Once scan complete, see the book metadata changes were reverted. 5. See the wrong precedence order shown in the log file. ### Audiobookshelf version v2.8.1 ### How are you running audiobookshelf? Docker
deekerman 2026-02-20 10:13:03 -05:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@advplyr commented on GitHub (Mar 18, 2024):

I wasn't able to reproduce the issue in my test.

The precedence in the log is actually correct because Abs iterates through the array from the lowest precedence to the highest, overwriting metadata as it takes precedence.

I would suggest opening up the JSON file at /metadata/items/1633d10f-837c-496e-ac2b-da990c9bbcc2/metadata.json and verifying that it has the correct data in it. Once you make a change you should see it reflected in that file.

According to the log the author name "J. N. Chaney" was what was saved in that JSON file and the author name "J.N. Chaney" is what was saved in the database for that book at the time of the scan.

The scheduled scan and a manual scan is using the same code so it shouldn't make any difference. The only way it could make a difference perhaps is if something on your system is changing over a longer period of time that you wouldn't see by running a manual scan.

In my testing I changed an author on a book then set up a scheduled scan to run in 5 minutes. If you are able to find more consistent reproduction steps that can help identify what is going on. Also providing more information about your specific setup, for example CIFS is known to have issues due to not respecting file inode values.

@advplyr commented on GitHub (Mar 18, 2024): I wasn't able to reproduce the issue in my test. The precedence in the log is actually correct because Abs iterates through the array from the lowest precedence to the highest, overwriting metadata as it takes precedence. I would suggest opening up the JSON file at `/metadata/items/1633d10f-837c-496e-ac2b-da990c9bbcc2/metadata.json` and verifying that it has the correct data in it. Once you make a change you should see it reflected in that file. According to the log the author name "J. N. Chaney" was what was saved in that JSON file and the author name "J.N. Chaney" is what was saved in the database for that book at the time of the scan. The scheduled scan and a manual scan is using the same code so it shouldn't make any difference. The only way it could make a difference perhaps is if something on your system is changing over a longer period of time that you wouldn't see by running a manual scan. In my testing I changed an author on a book then set up a scheduled scan to run in 5 minutes. If you are able to find more consistent reproduction steps that can help identify what is going on. Also providing more information about your specific setup, for example CIFS is known to have issues due to not respecting file inode values.
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-advplyr#1824
No description provided.