Skip to content

Conversation

@MythodeaLoL
Copy link

Fix: Accurate category detection for watch/import; enforce Default category; API key override; UI and config updates

Description

This PR fixes category detection regressions introduced after merging commit 2e9d7dd into 4248c3d and brings parity with the changes from branch 04.01.26-drondeseries-altmount-main.

Summary of changes

  • Fix watcher category detection: the watcher no longer uses the first path segment as a category. Category is detected only when the watched file path starts with a configured SABnzbd category subdirectory (longest-prefix match).
  • Ensure imported files under /import are recognized as category imports when placed inside a configured category path.
  • Upload via UI (/queue) with a selected category correctly resolves to that category's directory (behavior verified).
  • Add a system Default category:
    • Name is immutable ("Default"), cannot be removed or renamed via UI.
    • Default is configurable in YAML with order, priority, and dir (dir defaults to complete, no leading slash).
    • Default category values are loaded/saved from config.yaml (no hardcoded path).
  • Make sabnzbd.complete_dir a virtual path relative to the mount point (default /) and normalize dirs without leading slashes.
  • Add API key override in config.yaml:
    • config.api.key_override (32 chars) is used instead of the DB key if set and valid.
    • Regenerating the API key will also update key_override when present.
  • UI changes:
    • Category inputs replaced by selects (None + existing SABnzbd categories) in Upload NZB Files and ARR config pages.
    • Default category UI: name readonly, but order/priority/dir editable.
  • Misc fixes:
    • Replaced usage of a non-existing ConfigManager method with UpdateConfig + SaveConfig.
    • Logging improved to show category values instead of pointer addresses.
  • Tests: added/updated tests for category detection and related handlers.

Key files changed

  • Backend:
    • internal/importer/scanner/watcher.go (getCategoryFromPath, watcher logic)
    • internal/importer/service.go (buildCategoryPath / calculateProcessVirtualDir)
    • internal/config/manager.go (Default category enforcement, complete_dir handling, API key override)
    • internal/api/parsers.go (validateAPIKey)
    • internal/api/auth_handlers.go (regenerate API key / config save)
    • internal/api/sabnzbd_handlers.go (getDefaultCategory / buildCategoryPath)
    • config.sample.yaml
  • Frontend:
    • frontend/src/components/config/SABnzbdConfigSection.tsx (Default category UI)
    • frontend/src/components/config/ArrsConfigSection.tsx (category select)
    • frontend/src/components/config/ArrsInstanceCard.tsx (category select prop)
    • frontend/src/components/queue/DragDropUpload.tsx (category select)
  • Misc: logging and handler fixes

Migration / Upgrade notes

  • Update config.yaml to include the Default category and optionally api.key_override (see config.sample.yaml).
  • sabnzbd.complete_dir is now relative to the mount point; remove leading slashes in dir values (code normalizes them but keep this in mind).
  • Confirm Default category values in your config if you previously relied on implicit/hardcoded defaults.

How to test

  1. Configure SABnzbd categories (e.g., sonarr/, filmes/download/mov).
  2. Place an NZB in the watch dir under a category path:
    • e.g. /.../sync_nzbs/filmes/download/mov/torrent/interestelar.nzb
    • Confirm the matching category is applied and the import ends in the category dir.
  3. Import files manually into /import inside a category path and confirm category detection.
  4. Upload via Upload NZB Files (/queue) and select a category — confirm file goes to category dir.
  5. Confirm Default category exists in UI and cannot be renamed/removed; verify order/priority/dir editable.
  6. Set config.api.key_override to a 32-char key and verify API auth uses it. Regenerate the API key in UI and confirm both DB and config are updated.

@drondeseries drondeseries merged commit 4654beb into drondeseries:main Jan 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants