[PR #4088] [MERGED] Fix empty series delete check #4165

Closed
opened 2026-04-25 00:18:37 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/4088
Author: @nichwall
Created: 3/8/2025
Status: Merged
Merged: 3/9/2025
Merged by: @advplyr

Base: masterHead: checkRemoveAuthors_fix


📝 Commits (3)

  • 167617c Add: transaction to empty author remove
  • 84e20e0 Fix: empty series delete flakiness
  • 8f308c6 Close RSS feeds after removing empty series

📊 Changes

1 file changed (+80 additions, -55 deletions)

View changed files

📝 server/routers/ApiRouter.js (+80 -55)

📄 Description

Brief summary

This PR fixes an issue where the LibraryItemController test would fail occasionally.

Which issue is fixed?

No issue number, referenced in https://github.com/advplyr/audiobookshelf/pull/4055.

In-depth Description

This PR changes the "author with zero books" check to happen in a Sequelize transaction to ensure race conditions do not happen due to changes in the database between checking the database and deleting the author. This PR also changes the "series with zero books" check to work in the same way.

The issue was specific to the "series with zero books" check. The change to the author function is not strictly necessary, but may as well add the transaction so it does not become an issue in the future.

The previous version of "series with zero books" check would then iterate over each series to do the following actions:

  • Check if series is empty
  • Delete existing RSS feeds for the series
  • Delete the series

This resulted in multiple function calls to delete the series and makes it difficult to revert in case an error occurs during the cleanup, instead of relying on deleting the series to cascade and delete the associated RSS feed.

How have you tested this?

Verified with existing unit tests, and no failures occurred after running the test over 600 times (previously the test would fail within 100 runs).

Screenshots

N/A


🔄 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/4088 **Author:** [@nichwall](https://github.com/nichwall) **Created:** 3/8/2025 **Status:** ✅ Merged **Merged:** 3/9/2025 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `checkRemoveAuthors_fix` --- ### 📝 Commits (3) - [`167617c`](https://github.com/advplyr/audiobookshelf/commit/167617cce00a9f9fd5d3d2c3e50742fc66ecf01d) Add: transaction to empty author remove - [`84e20e0`](https://github.com/advplyr/audiobookshelf/commit/84e20e041c97271f7f3117c171d5980720665822) Fix: empty series delete flakiness - [`8f308c6`](https://github.com/advplyr/audiobookshelf/commit/8f308c6180cd7bbe742a2cfd8bcbedc558b558ac) Close RSS feeds after removing empty series ### 📊 Changes **1 file changed** (+80 additions, -55 deletions) <details> <summary>View changed files</summary> 📝 `server/routers/ApiRouter.js` (+80 -55) </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 This PR fixes an issue where the `LibraryItemController` test would fail occasionally. ## Which issue is fixed? No issue number, referenced in https://github.com/advplyr/audiobookshelf/pull/4055. ## In-depth Description This PR changes the "author with zero books" check to happen in a Sequelize transaction to ensure race conditions do not happen due to changes in the database between checking the database and deleting the author. This PR also changes the "series with zero books" check to work in the same way. The issue was specific to the "series with zero books" check. The change to the author function is not strictly necessary, but may as well add the transaction so it does not become an issue in the future. The previous version of "series with zero books" check would then iterate over each series to do the following actions: - Check if series is empty - Delete existing RSS feeds for the series - Delete the series This resulted in multiple function calls to delete the series and makes it difficult to revert in case an error occurs during the cleanup, instead of relying on deleting the series to cascade and delete the associated RSS feed. ## How have you tested this? Verified with existing unit tests, and no failures occurred after running the test over 600 times (previously the test would fail within 100 runs). ## Screenshots N/A --- <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:18:37 +02:00
adam closed this issue 2026-04-25 00:18:37 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#4165