Fix cross-platform CUE split path resolution and ManualImport#621
Open
mprachar wants to merge 3 commits intoUnpackerr:mainfrom
Open
Fix cross-platform CUE split path resolution and ManualImport#621mprachar wants to merge 3 commits intoUnpackerr:mainfrom
mprachar wants to merge 3 commits intoUnpackerr:mainfrom
Conversation
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>
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
getDownloadPathoutputPath folder fallback: When torrent title ≠ folder name, extract the actual folder name fromoutputPathand try configuredpathsbefore falling back to the raw (often unusable) outputPathOutputPathfor ManualImport: Storerecord.OutputPathon Extract struct and use it for ManualImport'sFolderparameter, so Lidarr receives a path it can accesscrossPlatformBasefor path comparison: On Linux,filepath.Basedoesn't split on backslashes, so Windows UNC paths from Lidarr returned the full path instead of the filenamefilterManualImportToNumberedTracksfallback: AfterMoveFilesmoves tracks back from_unpackerred,resp.NewFilesis often empty (especially multi-CD). Match CUE-split filenames by theNN - Title.flacpattern insteadresp.Size > 0trigger: ReplaceextractionHasFlacFiles(resp.NewFiles)withresp.Size > 0so ManualImport fires even when NewFiles tracking is incompleteMotivation
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:
Files Changed
pkg/unpackerr/handlers.goOutputPathto Extract struct;getDownloadPathoutputFolder fallback;resp.Size > 0triggerpkg/unpackerr/lidarr.gocrossPlatformBase(); basename filter;filterManualImportToNumberedTracks; storeOutputPath; use for ManualImport folderRelated
🤖 Generated with Claude Code