mirror of
https://github.com/Belphemur/CBZOptimizer.git
synced 2026-07-22 03:15:41 +02:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user