fix: possible race condition

This commit is contained in:
Antoine Aflalo
2025-09-09 16:58:42 -04:00
parent fe8c5606fc
commit 0a7cc506fd

View File

@@ -148,7 +148,8 @@ func (converter *Converter) ConvertChapter(ctx context.Context, chapter *manga.C
}
pagesMutex.Lock()
pages = append(pages, convertedPage.Page)
progress(fmt.Sprintf("Converted %d/%d pages to %s format", len(pages), totalPages, converter.Format()), uint32(len(pages)), totalPages)
currentTotalPages := atomic.LoadUint32(&totalPages)
progress(fmt.Sprintf("Converted %d/%d pages to %s format", len(pages), currentTotalPages, converter.Format()), uint32(len(pages)), currentTotalPages)
pagesMutex.Unlock()
}(page)
}