This pull request refactors how audiobook base directories and manual import paths are computed, making directory structure generation more predictable and testable. The changes focus on improving the handling of file naming patterns for both regular and manual imports, and add tests to ensure correctness.
Directory and Path Computation Improvements:
- Refactored
ComputeAudiobookBaseDirectoryFromPatternto strip file-specific variables (like{DiskNumber}and{ChapterNumber}) from the naming pattern, ensuring only directory-level metadata is used to build the base path. The method now combines the cleaned pattern with the root path and returns the full directory path, rather than extracting a directory from a file path. [1] [2] - Updated manual import path generation in
GenerateManualImportPathAsyncto use a simplified directory pattern ({Series}/{Title}or{Title}) and to always include the correct file extension. The result is a full path combining the audiobook's base path and the generated relative path. [1] [2]
Testing Enhancements:
- Added a new test file
LibraryController_BasePathTests.cswith unit tests forComputeAudiobookBaseDirectoryFromPattern, verifying correct directory paths for both series and non-series audiobooks.
General Codebase Improvements:
- Added
System.Text.RegularExpressionsimport to support pattern cleaning in directory computation.
Automated canary build