Skip to content

Commit d447adc

Browse files
committed
Index: Don't fail if thumbs for a sidecar file cannot be created
Signed-off-by: Michael Mayer <michael@photoprism.app>
1 parent 41da164 commit d447adc

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

internal/photoprism/index_related.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,10 @@ func IndexRelated(related RelatedFiles, ind *Index, o IndexOptions) (result Inde
7171

7272
// Create JPEG sidecar for media files in other formats so that thumbnails can be created.
7373
if o.Convert && f.IsMedia() && !f.HasPreviewImage() {
74-
// Skip with warning if preview image could not be created.
74+
// Try to create a preview image; if this fails, log and continue without failing the whole group.
7575
if img, imgErr := ind.convert.ToImage(f, false); imgErr != nil {
76-
result.Err = fmt.Errorf("index: could not create preview image for %s", clean.Log(f.RootRelName()))
77-
log.Error(result.Err)
78-
result.Status = IndexFailed
76+
log.Warnf("index: could not create preview image for %s (%s)", clean.Log(f.RootRelName()), imgErr)
77+
// Continue indexing other related files without changing the overall success status.
7978
continue
8079
} else if img == nil {
8180
log.Debugf("index: skipped creating preview image for %s", clean.Log(f.RootRelName()))
@@ -84,8 +83,8 @@ func IndexRelated(related RelatedFiles, ind *Index, o IndexOptions) (result Inde
8483

8584
// Skip with warning if thumbs could not be created.
8685
if thumbsErr := img.GenerateThumbnails(ind.thumbPath(), false); thumbsErr != nil {
87-
result.Err = fmt.Errorf("index: failed to generate thumbnails for %s (%s)", clean.Log(f.RootRelName()), thumbsErr.Error())
88-
result.Status = IndexFailed
86+
log.Warnf("index: failed to generate thumbnails for %s (%s)", clean.Log(f.RootRelName()), thumbsErr.Error())
87+
// Continue indexing; preview image exists and other related files may still succeed.
8988
continue
9089
}
9190

internal/photoprism/index_related_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ func TestIndexRelated(t *testing.T) {
1515
t.Run("2018-04-12 19_24_49.gif", func(t *testing.T) {
1616
cfg := config.TestConfig()
1717

18+
/* TODO: Investigate and resolve sporadic test failures
19+
cfg := config.NewTestConfig("index-related-gif")
20+
21+
// Ensure a clean originals/cache to avoid duplicate-by-hash from previous tests.
22+
_ = cfg.RemoveTestData()
23+
_ = fs.MkdirAll(cfg.OriginalsPath()) */
24+
1825
testFile, err := NewMediaFile("testdata/2018-04-12 19_24_49.gif")
1926

2027
if err != nil {
@@ -72,6 +79,13 @@ func TestIndexRelated(t *testing.T) {
7279
t.Run("apple-test-2.jpg", func(t *testing.T) {
7380
cfg := config.TestConfig()
7481

82+
/* TODO: Investigate and resolve sporadic test failures
83+
cfg := config.NewTestConfig("index-related-apple")
84+
85+
// Ensure a clean originals/cache to avoid duplicate-by-hash from previous tests.
86+
_ = cfg.RemoveTestData()
87+
_ = fs.MkdirAll(cfg.OriginalsPath()) */
88+
7589
testFile, err := NewMediaFile("testdata/apple-test-2.jpg")
7690

7791
if err != nil {

0 commit comments

Comments
 (0)