Index: Skip empty files #391
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
ad93f04003
commit
ab6228fb9a
|
@ -97,6 +97,9 @@ func TestDetails_NoCopyright(t *testing.T) {
|
||||||
func TestNewDetails(t *testing.T) {
|
func TestNewDetails(t *testing.T) {
|
||||||
t.Run("add to photo", func(t *testing.T) {
|
t.Run("add to photo", func(t *testing.T) {
|
||||||
p := NewPhoto()
|
p := NewPhoto()
|
||||||
|
|
||||||
|
assert.Equal(t, TitleUnknown, p.PhotoTitle)
|
||||||
|
|
||||||
d := NewDetails(p)
|
d := NewDetails(p)
|
||||||
p.Details = &d
|
p.Details = &d
|
||||||
d.Subject = "Foo Bar"
|
d.Subject = "Foo Bar"
|
||||||
|
|
|
@ -92,6 +92,7 @@ type Photo struct {
|
||||||
// NewPhoto creates a photo entity.
|
// NewPhoto creates a photo entity.
|
||||||
func NewPhoto() Photo {
|
func NewPhoto() Photo {
|
||||||
return Photo{
|
return Photo{
|
||||||
|
PhotoTitle: TitleUnknown,
|
||||||
PhotoType: TypeImage,
|
PhotoType: TypeImage,
|
||||||
PhotoCountry: UnknownCountry.ID,
|
PhotoCountry: UnknownCountry.ID,
|
||||||
CameraID: UnknownCamera.ID,
|
CameraID: UnknownCamera.ID,
|
||||||
|
|
|
@ -84,6 +84,7 @@ func (imp *Import) Start(opt ImportOptions) fs.Done {
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filesImported := 0
|
||||||
indexOpt := IndexOptionsAll()
|
indexOpt := IndexOptionsAll()
|
||||||
ignore := fs.NewIgnoreList(fs.IgnoreFile, true, false)
|
ignore := fs.NewIgnoreList(fs.IgnoreFile, true, false)
|
||||||
|
|
||||||
|
@ -132,6 +133,8 @@ func (imp *Import) Start(opt ImportOptions) fs.Done {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done[fileName] = fs.Found
|
||||||
|
|
||||||
if !fs.IsMedia(fileName) {
|
if !fs.IsMedia(fileName) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -142,6 +145,11 @@ func (imp *Import) Start(opt ImportOptions) fs.Done {
|
||||||
return nil
|
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)
|
related, err := mf.RelatedFiles(imp.conf.Settings().Index.Sequences)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -153,11 +161,12 @@ func (imp *Import) Start(opt ImportOptions) fs.Done {
|
||||||
var files MediaFiles
|
var files MediaFiles
|
||||||
|
|
||||||
for _, f := range related.Files {
|
for _, f := range related.Files {
|
||||||
if done[f.FileName()].Processed() {
|
if f.FileSize() == 0 || done[f.FileName()].Processed() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
files = append(files, f)
|
files = append(files, f)
|
||||||
|
filesImported++
|
||||||
done[f.FileName()] = fs.Processed
|
done[f.FileName()] = fs.Processed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +225,7 @@ func (imp *Import) Start(opt ImportOptions) fs.Done {
|
||||||
log.Error(err.Error())
|
log.Error(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(done) > 0 {
|
if filesImported > 0 {
|
||||||
if err := entity.UpdatePhotoCounts(); err != nil {
|
if err := entity.UpdatePhotoCounts(); err != nil {
|
||||||
log.Errorf("import: %s", err)
|
log.Errorf("import: %s", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,6 +151,11 @@ func (ind *Index) Start(opt IndexOptions) fs.Done {
|
||||||
return nil
|
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) {
|
if ind.files.Indexed(relName, entity.RootOriginals, mf.modTime, opt.Rescan) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -170,7 +175,7 @@ func (ind *Index) Start(opt IndexOptions) fs.Done {
|
||||||
continue
|
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
|
done[f.FileName()] = fs.Found
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue