fix(converter): preserve OriginalName through conversion and fix race

- Fix critical bug: convertPageFile and splitAndConvert now copy
  OriginalName to the output PageFile so --keep-filenames works
  end-to-end on actually-converted pages.
- Fix concurrency race: ExtractChapter deduplicates OriginalName when
  source archive has same base filename in different subdirectories.
- Fix collision fallback: resolvePageName loops until an unused
  indexed name is found instead of single-shot assignment.
- Fix gofmt indentation in optimize_command.go.
This commit is contained in:
Antoine Aflalo
2026-07-21 19:45:25 -04:00
parent f3ba585c13
commit 21f92bc6f5
5 changed files with 147 additions and 19 deletions
+11 -11
View File
@@ -24,10 +24,10 @@ func init() {
RunE: ConvertCbzCommand,
Args: cobra.ExactArgs(1),
}
// Setup common flags (format, quality, override, split, timeout)
setupCommonFlags(command, &converterType, 85, false, false, false)
// Setup optimize-specific flags
command.Flags().IntP("parallelism", "n", 2, "Number of chapters to convert in parallel")
@@ -128,15 +128,15 @@ func ConvertCbzCommand(cmd *cobra.Command, args []string) error {
log.Debug().Int("worker_id", workerID).Msg("Worker started")
for path := range fileChan {
log.Debug().Int("worker_id", workerID).Str("file_path", path).Msg("Worker processing file")
err := utils2.Optimize(&utils2.OptimizeOptions{
ChapterConverter: chapterConverter,
Path: path,
Quality: quality,
Override: override,
Split: split,
KeepFilenames: keepFilenames,
Timeout: timeout,
})
err := utils2.Optimize(&utils2.OptimizeOptions{
ChapterConverter: chapterConverter,
Path: path,
Quality: quality,
Override: override,
Split: split,
KeepFilenames: keepFilenames,
Timeout: timeout,
})
if err != nil {
log.Error().Int("worker_id", workerID).Str("file_path", path).Err(err).Msg("Worker encountered error")
errMutex.Lock()