[PR #4857] Feat/metadata id matching #4357

Open
opened 2026-04-25 00:19:24 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/4857
Author: @Cutch
Created: 11/25/2025
Status: 🔄 Open

Base: masterHead: feat/metadata-id-matching


📝 Commits (9)

  • 6ac0a8a Add id to the metadata json and use it when moving files if ino cannot be matched
  • 736a939 Add api to update all metadata files
  • 63a97b3 Add check for copied files
  • d5cd4f7 Fix debug log metadata save title
  • 94e1301 Update absId to id
  • dbcad61 Add migration
  • 9934537 Merge branch 'advplyr:master' into feat/metadata-id-matching
  • cf18cd9 Merge branch 'advplyr:master' into feat/metadata-id-matching
  • d46cc2d Merge branch 'advplyr:master' into feat/metadata-id-matching

📊 Changes

8 files changed (+100 additions, -2 deletions)

View changed files

📝 server/controllers/ToolsController.js (+23 -0)
📝 server/migrations/changelog.md (+1 -0)
server/migrations/v2.31.1-update-metadata-json-with-id.js (+48 -0)
📝 server/models/LibraryItem.js (+3 -1)
📝 server/routers/ApiRouter.js (+1 -0)
📝 server/scanner/BookScanner.js (+1 -0)
📝 server/scanner/LibraryScanner.js (+22 -1)
📝 server/scanner/PodcastScanner.js (+1 -0)

📄 Description

Brief summary

Add an api to sync metadata files. And add the abs id to the metadata.json to support when inode detection fails.

Which issue is fixed?

NA

In-depth Description

This PR does two things, first it adds a tool api the syncs all metadata files when toggling "Store metadata with item info" metadata files are not updated until a change is made. This has led to adding and remove tags on all files to update all library items. The api POST /tools/batch/update-metadata-files can be used to scan and update all items in the library.

The second change is adding the abs item id to the metadata.json. inode are not always supported on different systems/copying changing files makes a new inode. Storing the abs id in the metadata helps limit issues when files are moved and change.

I have noticed with windows inodes do not always work. Renames are detected in Watcher, but Scanner treats items like a new item. Ideally Watcher should pass this info directly into Scanner instead of relying on inodes. However, even that may not work on all systems, the metadata.json id should allow a much wider range of compatibility.
Protection when copying is added to prevent a copy from changing the original library item.
If an item cannot be detected or a copy is detected the new item will still get a new library entry/id.

How have you tested this?

Locally tested for the metadata changes, copying, moving, deleting, creating. Api tested via postman.

Screenshots


🔄 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/4857 **Author:** [@Cutch](https://github.com/Cutch) **Created:** 11/25/2025 **Status:** 🔄 Open **Base:** `master` ← **Head:** `feat/metadata-id-matching` --- ### 📝 Commits (9) - [`6ac0a8a`](https://github.com/advplyr/audiobookshelf/commit/6ac0a8a678bdfd702e53cabd9a09cfcf44aabc82) Add id to the metadata json and use it when moving files if ino cannot be matched - [`736a939`](https://github.com/advplyr/audiobookshelf/commit/736a939284c2e20c10c113698549cf7af384b527) Add api to update all metadata files - [`63a97b3`](https://github.com/advplyr/audiobookshelf/commit/63a97b3c40b7cc67ac49d75fa0ad9f207d501db7) Add check for copied files - [`d5cd4f7`](https://github.com/advplyr/audiobookshelf/commit/d5cd4f794469b8b0ef5a6956b36cfe52ca4825c7) Fix debug log metadata save title - [`94e1301`](https://github.com/advplyr/audiobookshelf/commit/94e13014ed27cd2023f0b792d8b26fb7457034cd) Update absId to id - [`dbcad61`](https://github.com/advplyr/audiobookshelf/commit/dbcad610cb12ebdff71564c4b6fe03b465745ae3) Add migration - [`9934537`](https://github.com/advplyr/audiobookshelf/commit/99345371735cdc54bfc6f3215ffd71521b5cdf1a) Merge branch 'advplyr:master' into feat/metadata-id-matching - [`cf18cd9`](https://github.com/advplyr/audiobookshelf/commit/cf18cd9fbf18fefc88bb7db8ad83588fed15264b) Merge branch 'advplyr:master' into feat/metadata-id-matching - [`d46cc2d`](https://github.com/advplyr/audiobookshelf/commit/d46cc2dce69ec948adca522f111b596cd0f5103c) Merge branch 'advplyr:master' into feat/metadata-id-matching ### 📊 Changes **8 files changed** (+100 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `server/controllers/ToolsController.js` (+23 -0) 📝 `server/migrations/changelog.md` (+1 -0) ➕ `server/migrations/v2.31.1-update-metadata-json-with-id.js` (+48 -0) 📝 `server/models/LibraryItem.js` (+3 -1) 📝 `server/routers/ApiRouter.js` (+1 -0) 📝 `server/scanner/BookScanner.js` (+1 -0) 📝 `server/scanner/LibraryScanner.js` (+22 -1) 📝 `server/scanner/PodcastScanner.js` (+1 -0) </details> ### 📄 Description <!-- For Work In Progress Pull Requests, please use the Draft PR feature, see https://github.blog/2019-02-14-introducing-draft-pull-requests/ for further details. If you do not follow this template, the PR may be closed without review. Please ensure all checks pass. If you are a new contributor, the workflows will need to be manually approved before they run. --> ## Brief summary Add an api to sync metadata files. And add the abs id to the metadata.json to support when inode detection fails. <!-- Please provide a brief summary of what your PR attempts to achieve. --> ## Which issue is fixed? <!-- Which issue number does this PR fix? Ex: "Fixes #1234" --> NA ## In-depth Description This PR does two things, first it adds a tool api the syncs all metadata files when toggling "Store metadata with item info" metadata files are not updated until a change is made. This has led to adding and remove tags on all files to update all library items. The api POST /tools/batch/update-metadata-files can be used to scan and update all items in the library. The second change is adding the abs item id to the metadata.json. inode are not always supported on different systems/copying changing files makes a new inode. Storing the abs id in the metadata helps limit issues when files are moved and change. I have noticed with windows inodes do not always work. Renames are detected in Watcher, but Scanner treats items like a new item. Ideally Watcher should pass this info directly into Scanner instead of relying on inodes. However, even that may not work on all systems, the metadata.json id should allow a much wider range of compatibility. Protection when copying is added to prevent a copy from changing the original library item. If an item cannot be detected or a copy is detected the new item will still get a new library entry/id. <!-- Describe your solution in more depth. How does it work? Why is this the best solution? Does it solve a problem that affects multiple users or is this an edge case for your setup? --> ## How have you tested this? <!-- Please describe in detail with reproducible steps how you tested your changes. --> Locally tested for the metadata changes, copying, moving, deleting, creating. Api tested via postman. ## Screenshots <!-- If your PR includes any changes to the web client, please include screenshots or a short video from before and after your changes. --> --- <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:19:24 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#4357