mirror of
https://github.com/Belphemur/CBZOptimizer.git
synced 2026-07-21 19:05:39 +02:00
fix(memory): use staging folder to avoid keeping everything in memory
Co-authored-by: Belphemur <197810+Belphemur@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Fixes #203
This commit is contained in:
@@ -91,6 +91,15 @@ func Optimize(options *OptimizeOptions) error {
|
||||
return fmt.Errorf("failed to convert chapter")
|
||||
}
|
||||
|
||||
// Clean up the staging temp folder (if any) used to hold converted page
|
||||
// contents on disk once we're done with the chapter, regardless of
|
||||
// success or failure below.
|
||||
defer func() {
|
||||
if cleanupErr := convertedChapter.Cleanup(); cleanupErr != nil {
|
||||
log.Warn().Str("file", chapter.FilePath).Err(cleanupErr).Msg("Failed to remove staging temp folder")
|
||||
}
|
||||
}()
|
||||
|
||||
log.Debug().
|
||||
Str("file", chapter.FilePath).
|
||||
Int("original_pages", len(chapter.Pages)).
|
||||
|
||||
Reference in New Issue
Block a user