mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-06 06:10:09 +00:00
Add remote path mapping for qBittorrent integration
Implements remote-to-local path mapping for qBittorrent downloads, allowing the app to handle differing filesystem paths between qBittorrent and the local environment (e.g., remote seedboxes, Docker). Adds UI controls in admin settings and setup wizard, validates mapping configuration, and applies path transformation in download and import processors. Updates documentation, API routes, and data models to support the new feature. Also improves library scan logic to remove stale records and reset orphaned audiobooks and requests. Increases minimum torrent score threshold from 30 to 50 in search and ranking logic, and exposes torrent source URLs in the admin UI.
This commit is contained in:
@@ -48,7 +48,12 @@ Free, open-source BitTorrent client with comprehensive Web API.
|
||||
- `download_client_password` - qBittorrent password
|
||||
- `download_dir` - Download save path (passed to qBittorrent for all torrents)
|
||||
|
||||
Validation: All fields checked before service initialization.
|
||||
**Optional (Remote Path Mapping):**
|
||||
- `download_client_remote_path_mapping_enabled` - Enable path mapping (boolean as string "true"/"false")
|
||||
- `download_client_remote_path` - Remote path prefix from qBittorrent
|
||||
- `download_client_local_path` - Local path prefix for ReadMeABook
|
||||
|
||||
Validation: All required fields checked before service initialization. Path mapping fields validated when enabled.
|
||||
|
||||
**Singleton Invalidation:**
|
||||
Service uses singleton pattern for performance. When settings change (via admin settings page), singleton is invalidated to force reload:
|
||||
@@ -72,6 +77,53 @@ Service uses singleton pattern for performance. When settings change (via admin
|
||||
|
||||
This prevents issues where category retains old save path after user changes `download_dir` setting.
|
||||
|
||||
## Remote Path Mapping
|
||||
|
||||
**Use Case:** qBittorrent runs on different machine/container with different filesystem perspective.
|
||||
|
||||
**Example Scenario:**
|
||||
- qBittorrent reports: `/remote/mnt/d/done/Audiobook.Name`
|
||||
- ReadMeABook needs: `/downloads/Audiobook.Name`
|
||||
- Mapping: Remote `/remote/mnt/d/done` → Local `/downloads`
|
||||
|
||||
**Configuration:**
|
||||
1. Admin Settings → Download Client → Enable Remote Path Mapping
|
||||
2. Enter remote path (as reported by qBittorrent)
|
||||
3. Enter local path (accessible to ReadMeABook)
|
||||
4. Test connection validates local path exists
|
||||
5. Save settings
|
||||
|
||||
**Implementation:**
|
||||
- `PathMapper` utility (`src/lib/utils/path-mapper.ts`) handles transformation
|
||||
- Applied in `monitor-download.processor.ts` when download completes
|
||||
- Applied in `retry-failed-imports.processor.ts` for failed imports
|
||||
- Uses simple prefix replacement with path normalization
|
||||
- Graceful fallback: if path doesn't match remote prefix, returns unchanged
|
||||
|
||||
**Path Transformation:**
|
||||
```typescript
|
||||
// Input from qBittorrent
|
||||
qbPath = "/remote/mnt/d/done/Audiobook.Name"
|
||||
|
||||
// Config
|
||||
remotePath = "/remote/mnt/d/done"
|
||||
localPath = "/downloads"
|
||||
|
||||
// Output (used for file organization)
|
||||
organizePath = "/downloads/Audiobook.Name"
|
||||
```
|
||||
|
||||
**Validation:**
|
||||
- Local path accessibility checked during test connection
|
||||
- Prevents misconfiguration before save
|
||||
- Warning shown for existing downloads (mapping only affects new downloads)
|
||||
|
||||
**Behavior:**
|
||||
- Mapping only applies when enabled
|
||||
- If path doesn't start with remote prefix, returns original (logs warning)
|
||||
- Path normalization handles trailing slashes, backslashes, redundant separators
|
||||
- Works with both `content_path` and constructed `save_path + name`
|
||||
|
||||
## Data Models
|
||||
|
||||
```typescript
|
||||
@@ -107,6 +159,11 @@ type TorrentState = 'downloading' | 'uploading' | 'stalledDL' |
|
||||
- Checking existing categories before create/edit (avoid unnecessary 409 errors)
|
||||
- Invalidating service singleton when settings change (forces config reload)
|
||||
- Settings API calls `invalidateQBittorrentService()` after updating paths or credentials
|
||||
**10. Remote seedbox path mismatch** - qBittorrent on remote machine reports different filesystem paths. Fixed by:
|
||||
- Remote path mapping feature with toggle in admin settings and setup wizard
|
||||
- PathMapper utility for prefix replacement transformation
|
||||
- Local path validation during test connection
|
||||
- Applied in download completion and import retry processors
|
||||
|
||||
## Tech Stack
|
||||
|
||||
|
||||
Reference in New Issue
Block a user