diff --git a/internal/entity/details_test.go b/internal/entity/details_test.go index 8124c883c..0961b860b 100644 --- a/internal/entity/details_test.go +++ b/internal/entity/details_test.go @@ -97,6 +97,9 @@ func TestDetails_NoCopyright(t *testing.T) { func TestNewDetails(t *testing.T) { t.Run("add to photo", func(t *testing.T) { p := NewPhoto() + + assert.Equal(t, TitleUnknown, p.PhotoTitle) + d := NewDetails(p) p.Details = &d d.Subject = "Foo Bar" diff --git a/internal/entity/photo.go b/internal/entity/photo.go index 2ebf95029..a226c4a61 100644 --- a/internal/entity/photo.go +++ b/internal/entity/photo.go @@ -92,6 +92,7 @@ type Photo struct { // NewPhoto creates a photo entity. func NewPhoto() Photo { return Photo{ + PhotoTitle: TitleUnknown, PhotoType: TypeImage, PhotoCountry: UnknownCountry.ID, CameraID: UnknownCamera.ID, diff --git a/internal/photoprism/import.go b/internal/photoprism/import.go index 9dc23b017..ca8e11e1f 100644 --- a/internal/photoprism/import.go +++ b/internal/photoprism/import.go @@ -84,6 +84,7 @@ func (imp *Import) Start(opt ImportOptions) fs.Done { }() } + filesImported := 0 indexOpt := IndexOptionsAll() ignore := fs.NewIgnoreList(fs.IgnoreFile, true, false) @@ -132,6 +133,8 @@ func (imp *Import) Start(opt ImportOptions) fs.Done { return result } + done[fileName] = fs.Found + if !fs.IsMedia(fileName) { return nil } @@ -142,6 +145,11 @@ func (imp *Import) Start(opt ImportOptions) fs.Done { return nil } + if mf.FileSize() == 0 { + log.Infof("import: skipped empty file %s", txt.Quote(mf.BaseName())) + return nil + } + related, err := mf.RelatedFiles(imp.conf.Settings().Index.Sequences) if err != nil { @@ -153,11 +161,12 @@ func (imp *Import) Start(opt ImportOptions) fs.Done { var files MediaFiles for _, f := range related.Files { - if done[f.FileName()].Processed() { + if f.FileSize() == 0 || done[f.FileName()].Processed() { continue } files = append(files, f) + filesImported++ done[f.FileName()] = fs.Processed } @@ -216,7 +225,7 @@ func (imp *Import) Start(opt ImportOptions) fs.Done { log.Error(err.Error()) } - if len(done) > 0 { + if filesImported > 0 { if err := entity.UpdatePhotoCounts(); err != nil { log.Errorf("import: %s", err) } diff --git a/internal/photoprism/index.go b/internal/photoprism/index.go index 3d8e2bbd7..50caa2f8a 100644 --- a/internal/photoprism/index.go +++ b/internal/photoprism/index.go @@ -151,6 +151,11 @@ func (ind *Index) Start(opt IndexOptions) fs.Done { return nil } + if mf.FileSize() == 0 { + log.Infof("index: skipped empty file %s", txt.Quote(mf.BaseName())) + return nil + } + if ind.files.Indexed(relName, entity.RootOriginals, mf.modTime, opt.Rescan) { return nil } @@ -170,7 +175,7 @@ func (ind *Index) Start(opt IndexOptions) fs.Done { continue } - if ind.files.Indexed(f.RootRelName(), f.Root(), f.ModTime(), opt.Rescan) { + if f.FileSize() == 0 || ind.files.Indexed(f.RootRelName(), f.Root(), f.ModTime(), opt.Rescan) { done[f.FileName()] = fs.Found continue }