fix(vision): use consistent error variable naming and add debug logging

- Rename fileErr to err in GenerateCaption for consistency with named return
- Add debug log when caption generation fails (was only a comment before)
- Add context to thumbnail error log in DetectNSFW for better debugging

Fixes #5398
This commit is contained in:
Vedant Madane 2026-01-12 01:51:11 +05:30
parent 8f298857a6
commit 00a6bfc858

View file

@ -35,16 +35,16 @@ func (m *MediaFile) GenerateCaption(captionSrc entity.Src) (caption *vision.Capt
size := vision.Thumb(vision.ModelTypeCaption)
// Get thumbnail filenames for the selected sizes.
fileName, fileErr := m.Thumbnail(Config().ThumbCachePath(), size.Name)
fileName, err := m.Thumbnail(Config().ThumbCachePath(), size.Name)
if fileErr != nil {
return caption, fileErr
if err != nil {
return caption, err
}
// Get matching labels from computer vision model.
// Generate a caption using the configured vision model.
if caption, _, err = vision.GenerateCaption(vision.Files{fileName}, media.SrcLocal); err != nil {
// Failed.
log.Debugf("vision: %s in %s (generate caption)", err, clean.Log(m.RootRelName()))
} else if caption.Text != "" {
if captionSrc != entity.SrcAuto {
caption.Source = captionSrc
@ -128,7 +128,7 @@ func (m *MediaFile) DetectNSFW() bool {
filename, err := m.Thumbnail(Config().ThumbCachePath(), thumb.Fit720)
if err != nil {
log.Error(err)
log.Errorf("vision: %s in %s (thumbnail for nsfw)", err, clean.Log(m.RootRelName()))
return false
}