feat(backend): implement on-demand thumbnail generation
Some checks failed
Build and Publish Docker Image / deploy (push) Failing after 44s

When a thumbnail is requested but not yet available, attempt to generate
it synchronously on-demand instead of immediately falling back to the
placeholder image.

- Export thumbnail generation helpers from the jobs package.
- Update the Thumbnail handler to trigger on-demand generation if the
  thumbnail object is missing.
- Save the updated box metadata with the new thumbnail reference.
- Fall back to the placeholder image only if on-demand generation fails.
This commit is contained in:
2026-06-03 15:20:26 +03:00
parent 3b278642dc
commit eff831b142
2 changed files with 44 additions and 0 deletions

View File

@@ -141,6 +141,14 @@ func needsThumbnail(file services.File) bool {
return file.PreviewKind == "image" || file.PreviewKind == "video" || isTextThumbnailCandidate(file)
}
func NeedsThumbnail(file services.File) bool {
return needsThumbnail(file)
}
func GenerateThumbnailForFile(uploadService *services.UploadService, box services.Box, file services.File) (string, error) {
return generateThumbnail(uploadService, box, file)
}
func generateThumbnail(uploadService *services.UploadService, box services.Box, file services.File) (string, error) {
thumbnailName := "@thumb@" + file.ID + ".jpg"
object, err := uploadService.OpenFileObject(context.Background(), box, file)