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:
Copilot
2026-07-03 09:15:56 -04:00
committed by GitHub
parent f2a65425cf
commit c2f809ed2c
13 changed files with 352 additions and 33 deletions
+9
View File
@@ -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)).