fix(chapter): fix chapter conversion.

Still need to figure out the memory issues

Consolidates image conversion logic into a dedicated method.

This change streamlines the conversion process by centralizing the
setting of converted image data, extension, and size. It also
introduces a flag to track whether an image has been converted.

The old resource cleanup has been removed since it is not needed anymore.
This commit is contained in:
Antoine Aflalo
2025-02-14 10:03:35 -05:00
parent 4d3391273c
commit 23eb43c691
5 changed files with 125 additions and 31 deletions

View File

@@ -80,7 +80,6 @@ func (converter *Converter) ConvertChapter(chapter *manga.Chapter, quality uint8
go func(pageToConvert *manga.PageContainer) {
defer func() {
wgConvertedPages.Done()
pageToConvert.Close() // Clean up resources
<-guard
}()
@@ -243,9 +242,7 @@ func (converter *Converter) convertPage(container *manga.PageContainer, quality
if err != nil {
return nil, err
}
container.Page.Contents = converted
container.Page.Extension = ".webp"
container.Page.Size = uint64(converted.Len())
container.SetConverted(converted, ".webp");
return container, nil
}