mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-03 04:40:09 +00:00
SABnzbd path mapping + ASIN-based request deletion
Add bidirectional path mapping and complete_dir-aware category sync to the SABnzbd integration. Introduces PathMapper usage, complete_dir extraction, calculateCategoryPath(), and ensureCategory() logic to choose empty/relative/absolute category paths; ensureCategory is invoked before adding NZBs. Update singleton factory to load download_dir and path-mapping config from DownloadClientManager and recreate the service when config is not loaded. Make DownloadClientManager pass path-mapping config into the SABnzbd service. Change request deletion to remove plex_library records by ASIN (deleteMany) with a fallback to exact title/author matches so availability checks and deletions are consistent. Update documentation and tests to reflect the new behavior and APIs.
This commit is contained in:
@@ -100,9 +100,20 @@ model Request {
|
||||
- Queries plex_library table to get plexRatingKey from audiobook's plexGuid
|
||||
- Calls Plex DELETE `/library/metadata/{ratingKey}` endpoint with the ratingKey
|
||||
- Requires deletion enabled in Plex: Settings > Server > Library
|
||||
- Also clears plex_library cache records
|
||||
|
||||
5. **Soft Delete Request**
|
||||
5. **Delete plex_library Cache Records**
|
||||
- **Primary:** Delete by ASIN (same query as availability check)
|
||||
- `WHERE asin = audiobookAsin OR plexGuid CONTAINS audiobookAsin`
|
||||
- Ensures exact same record found during availability check gets deleted
|
||||
- **Fallback:** Delete by exact title/author (for legacy records without ASIN)
|
||||
- Only used if ASIN-based deletion finds no records
|
||||
- **Result:** Book immediately shows as NOT available, can be re-requested
|
||||
|
||||
6. **Clear Audiobook Linkage**
|
||||
- Reset audiobook.status to 'requested'
|
||||
- Clear plexGuid (Plex mode) or absItemId (ABS mode)
|
||||
|
||||
7. **Soft Delete Request**
|
||||
- UPDATE: `deletedAt = NOW(), deletedBy = adminUserId`
|
||||
- Preserves for audit trail and orphaned download tracking
|
||||
|
||||
@@ -201,6 +212,17 @@ where: {
|
||||
11. ✅ **Plex library item deletion fails** - Log error, continue with soft delete
|
||||
12. ✅ **No plexGuid present** - Skip Plex deletion (not yet in library)
|
||||
13. ✅ **Plex deletion not enabled in settings** - Log error, continue with soft delete
|
||||
14. ✅ **Title mismatch in plex_library** - ASIN-based deletion handles title variations (e.g., "(Unabridged)" suffix)
|
||||
15. ✅ **No ASIN available** - Falls back to exact title/author matching
|
||||
|
||||
## Fixed Issues ✅
|
||||
|
||||
**1. Book Shows "Available" After Deletion Until Library Scan**
|
||||
- **Issue:** Deleted books remained "available" until the next library scan
|
||||
- **Cause:** plex_library deletion used title/author matching, but availability check used ASIN matching
|
||||
- **Impact:** Title variations (e.g., "Book Title" vs "Book Title (Unabridged)") caused plex_library records to persist
|
||||
- **Fix:** Changed plex_library deletion to use ASIN-based matching (same as availability check)
|
||||
- **Result:** Books immediately show as NOT available after deletion, can be re-requested right away
|
||||
|
||||
## File Structure
|
||||
|
||||
|
||||
Reference in New Issue
Block a user