Skip to content

Fix cross-platform CUE split path resolution and ManualImport#621

Open
mprachar wants to merge 3 commits intoUnpackerr:mainfrom
mprachar:fix/cross-platform-cue-import
Open

Fix cross-platform CUE split path resolution and ManualImport#621
mprachar wants to merge 3 commits intoUnpackerr:mainfrom
mprachar:fix/cross-platform-cue-import

Conversation

@mprachar
Copy link

Summary

Fixes CUE split ManualImport for cross-platform setups (Linux unpackerr + Windows Starr apps, Docker with different mount paths). These bugs affect both FLAC+CUE and APE+CUE splitting.

  • getDownloadPath outputPath folder fallback: When torrent title ≠ folder name, extract the actual folder name from outputPath and try configured paths before falling back to the raw (often unusable) outputPath
  • OutputPath for ManualImport: Store record.OutputPath on Extract struct and use it for ManualImport's Folder parameter, so Lidarr receives a path it can access
  • crossPlatformBase for path comparison: On Linux, filepath.Base doesn't split on backslashes, so Windows UNC paths from Lidarr returned the full path instead of the filename
  • filterManualImportToNumberedTracks fallback: After MoveFiles moves tracks back from _unpackerred, resp.NewFiles is often empty (especially multi-CD). Match CUE-split filenames by the NN - Title.flac pattern instead
  • resp.Size > 0 trigger: Replace extractionHasFlacFiles(resp.NewFiles) with resp.Size > 0 so ManualImport fires even when NewFiles tracking is incomplete

Motivation

CUE splitting (introduced in xtractr v0.3.0) works correctly for extraction, but the ManualImport step to tell Lidarr about the split tracks fails silently in cross-platform environments. This is the most common deployment: Lidarr on Windows/Docker + unpackerr on Linux/Docker with NAS mounts.

The path comparison between Linux extraction paths and Windows ManualImport response paths always mismatches, resulting in "No split track files to import" for every album.

Testing

Tested end-to-end on a live setup:

  • Linux unpackerr (.13) + Windows Lidarr (.10/.12) + Synology NAS
  • APE+CUE albums: Buckethead, Aretha Franklin, Trans-Siberian Orchestra, Stray Cats
  • FLAC+CUE albums: Clutch, Chuck Berry, Keith Jarrett, Muddy Waters
  • ManualImport successfully triggered for split tracks via numbered track pattern fallback
  • Multi-CD box sets (6CD+) handled correctly

Files Changed

File Changes
pkg/unpackerr/handlers.go Add OutputPath to Extract struct; getDownloadPath outputFolder fallback; resp.Size > 0 trigger
pkg/unpackerr/lidarr.go crossPlatformBase(); basename filter; filterManualImportToNumberedTracks; store OutputPath; use for ManualImport folder

Related

🤖 Generated with Claude Code

When unpackerr runs on Linux but Starr apps run on Windows (or in
Docker with different mount paths), several issues prevent CUE splitting
from working end-to-end:

1. getDownloadPath: When the torrent title differs from the actual
   folder name (very common), the configured paths + title lookup fails.
   The fallback uses the raw outputPath from the Starr API, which is a
   UNC/Windows path unusable on Linux. Fix: extract the folder name from
   outputPath and try it against configured paths before falling back.

2. importSplitFlacTracks: The ManualImport API folder parameter was
   always item.Path (the local extraction path). On cross-platform
   setups, Lidarr can't access Linux paths. Fix: store the original
   outputPath from the Starr API on the Extract struct and use it for
   ManualImport, since Lidarr already knows that path.

3. filterManualImportToSplitTracks: Compared full file paths between
   Linux (NewFiles) and Windows (Lidarr ManualImport response). On
   Linux, filepath.Base doesn't split on backslashes, so Windows UNC
   paths returned the entire path instead of the filename. Fix: add
   crossPlatformBase() that normalizes backslashes before extracting
   the basename.

4. NewFiles tracking: After MoveFiles moves split tracks from the temp
   _unpackerred folder back to the original path, resp.NewFiles is
   often empty (especially for multi-CD albums with subdirectories).
   This caused extractionHasFlacFiles to return false, preventing
   importSplitFlacTracks from firing. Fix: trigger on resp.Size > 0
   instead. Add filterManualImportToNumberedTracks as a fallback that
   matches the CUE-split naming pattern (NN - Title.flac) when NewFiles
   is unavailable.

All fixes are platform-agnostic and benefit any cross-platform setup
including Docker deployments with different mount paths.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mprachar and others added 2 commits March 24, 2026 16:18
- Remove extractionHasFlacFiles (unused after resp.Size trigger change)
- Extract filterSplitOutputs helper from importSplitFlacTracks to
  bring function length under the 60-line funlen limit

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant