Backend: Don't import / index sidecar files without media file

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-05-13 17:42:25 +02:00
parent a123726d28
commit bd59dc2564
2 changed files with 32 additions and 31 deletions

View file

@ -28,7 +28,7 @@ func ImportWorker(jobs <-chan ImportJob) {
importPath := job.ImportOpt.Path
if related.Main == nil {
log.Warnf("import: no main file found for %s", job.FileName)
log.Warnf("import: no media file found for %s", txt.Quote(fs.RelativeName(job.FileName, importPath)))
continue
}

View file

@ -19,43 +19,44 @@ func IndexWorker(jobs <-chan IndexJob) {
opt := job.IndexOpt
ind := job.Ind
if related.Main != nil {
f := related.Main
if related.Main == nil {
log.Warnf("index: no media file found for %s", txt.Quote(fs.RelativeName(job.FileName, ind.originalsPath())))
continue
}
if opt.Convert && !f.HasJpeg() {
if converted, err := ind.convert.ToJpeg(f); err != nil {
log.Errorf("index: creating jpeg failed (%s)", err.Error())
} else {
if err := converted.ResampleDefault(ind.thumbPath(), false); err != nil {
log.Errorf("index: could not create default thumbnails (%s)", err.Error())
}
f := related.Main
related.Files = append(related.Files, converted)
}
}
if ind.conf.WriteJson() && !f.HasJson() {
if converted, err := ind.convert.ToJson(f); err != nil {
log.Errorf("index: creating jpeg failed (%s)", err.Error())
} else {
related.Files = append(related.Files, converted)
}
}
res := ind.MediaFile(f, opt, "")
done[f.FileName()] = true
if (res.Status == IndexAdded || res.Status == IndexUpdated) && f.IsJpeg() {
if err := f.ResampleDefault(ind.thumbPath(), false); err != nil {
if opt.Convert && !f.HasJpeg() {
if converted, err := ind.convert.ToJpeg(f); err != nil {
log.Errorf("index: creating jpeg failed (%s)", err.Error())
} else {
if err := converted.ResampleDefault(ind.thumbPath(), false); err != nil {
log.Errorf("index: could not create default thumbnails (%s)", err.Error())
}
}
log.Infof("index: %s main %s file %s", res, f.FileType(), txt.Quote(f.RelativeName(ind.originalsPath())))
} else {
log.Warnf("index: no main file for %s (conversion failed?)", txt.Quote(fs.RelativeName(job.FileName, ind.originalsPath())))
related.Files = append(related.Files, converted)
}
}
if ind.conf.WriteJson() && !f.HasJson() {
if converted, err := ind.convert.ToJson(f); err != nil {
log.Errorf("index: creating jpeg failed (%s)", err.Error())
} else {
related.Files = append(related.Files, converted)
}
}
res := ind.MediaFile(f, opt, "")
done[f.FileName()] = true
if (res.Status == IndexAdded || res.Status == IndexUpdated) && f.IsJpeg() {
if err := f.ResampleDefault(ind.thumbPath(), false); err != nil {
log.Errorf("index: could not create default thumbnails (%s)", err.Error())
}
}
log.Infof("index: %s main %s file %s", res, f.FileType(), txt.Quote(f.RelativeName(ind.originalsPath())))
for _, f := range related.Files {
if done[f.FileName()] {
continue