Skip to content

feat(media): extract archive downloads on import and handle missing root folder - #102

Open
Josh-Archer wants to merge 2 commits into
Chaptarr:developfrom
Josh-Archer:feat/import-archive-extraction
Open

feat(media): extract archive downloads on import and handle missing root folder#102
Josh-Archer wants to merge 2 commits into
Chaptarr:developfrom
Josh-Archer:feat/import-archive-extraction

Conversation

@Josh-Archer

Copy link
Copy Markdown
Contributor

Description

This PR enhances download import resilience with archive auto-extraction and robust missing root folder handling:

  1. Automatic Archive Extraction: Many ebook and audiobook releases are distributed as compressed archives (.zip, .tgz, .tar.gz). During completed download processing in DownloadedBooksImportService, if no loose media files exist in the downloaded folder, Chaptarr now automatically extracts supported archives into the directory using IArchiveService before proceeding with file matching and import.
  2. Typed Root Folder Exception on File Upgrades: In UpgradeMediaFileService, when upgrading an existing book file, a missing or unresolvable root folder previously resulted in a NullReferenceException crash. This is now caught early and throws a typed RootFolderNotFoundException with clear diagnostic logs.

Database Migration

NO

How was this tested?

  • Unit Tests:
    • Added unit tests in DownloadedBooksImportServiceFixture verifying archive extraction when direct media files are missing.
    • Added unit tests in UpgradeMediaFileServiceFixture verifying that RootFolderNotFoundException is cleanly thrown on missing root folder paths.
  • Environment: Tested on Linux (Docker / K3s) with multi-format ebook and audiobook imports.

Highlights & Assumptions

  • Highlights:
    • Eliminates manual unpacking steps for zipped releases and multipart downloads.
    • Uses the existing, tested IArchiveService (SharpZipLib) already registered in DI.
    • Replaces unhelpful NRE stack traces with actionable Servarr RootFolderNotFoundException error handling.
  • Assumptions:
    • Supported archive formats match ArchiveService capabilities (.zip, .tgz, .tar.gz).
    • Extraction occurs in-place within the completed download working folder before moving/hardlinking media files into the library.

AI Disclosure & Workflow Sharing

Note on AI: This implementation and test suite were developed and refined using agentic AI coding workflows (Codex / Claude 3.7). We understand and fully welcome the project's code review scrutiny. If the maintainers or community are interested, we are very happy to share our agentic harness, testing harness, and validation workflow setup!

@Josh-Archer
Josh-Archer force-pushed the feat/import-archive-extraction branch from 1c62792 to dc2c402 Compare August 29, 2026 21:43
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.

1 participant