Backend: Don't index sidecar files if main file failed
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
ca8a8466d4
commit
916e3a570c
5 changed files with 37 additions and 12 deletions
|
@ -85,6 +85,22 @@ type Photo struct {
|
|||
DeletedAt *time.Time `sql:"index" yaml:"DeletedAt,omitempty"`
|
||||
}
|
||||
|
||||
// NewPhoto creates a photo entity.
|
||||
func NewPhoto() Photo {
|
||||
return Photo{
|
||||
PhotoType: TypeImage,
|
||||
PhotoCountry: UnknownCountry.ID,
|
||||
Camera: &UnknownCamera,
|
||||
CameraID: UnknownCamera.ID,
|
||||
Lens: &UnknownLens,
|
||||
LensID: UnknownLens.ID,
|
||||
Location: &UnknownLocation,
|
||||
LocationID: UnknownLocation.ID,
|
||||
Place: &UnknownPlace,
|
||||
PlaceID: UnknownPlace.ID,
|
||||
}
|
||||
}
|
||||
|
||||
// SavePhotoForm saves a model in the database using form data.
|
||||
func SavePhotoForm(model Photo, form form.Photo, geoApi string) error {
|
||||
locChanged := model.PhotoLat != form.PhotoLat || model.PhotoLng != form.PhotoLng || model.PhotoCountry != form.PhotoCountry
|
||||
|
|
|
@ -131,14 +131,16 @@ func ImportWorker(jobs <-chan ImportJob) {
|
|||
|
||||
res := ind.MediaFile(related.Main, indexOpt, originalName)
|
||||
|
||||
log.Infof("import: %s main %s file %s", res, related.Main.FileType(), txt.Quote(related.Main.RelativeName(ind.originalsPath())))
|
||||
done[related.Main.FileName()] = true
|
||||
|
||||
if res.Success() {
|
||||
if err := entity.AddPhotoToAlbums(res.PhotoUID, opt.Albums); err != nil {
|
||||
log.Warn(err)
|
||||
}
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
|
||||
log.Infof("import: %s main %s file %s", res, related.Main.FileType(), txt.Quote(related.Main.RelativeName(ind.originalsPath())))
|
||||
done[related.Main.FileName()] = true
|
||||
} else {
|
||||
log.Warnf("import: no main file for %s (conversion to jpeg failed?)", fs.RelativeName(destinationMainFilename, imp.originalsPath()))
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName string) (
|
|||
|
||||
file, primaryFile := entity.File{}, entity.File{}
|
||||
|
||||
photo := entity.Photo{PhotoType: entity.TypeImage, PhotoCountry: entity.UnknownCountry.ID}
|
||||
photo := entity.NewPhoto()
|
||||
metaData := meta.Data{}
|
||||
description := entity.Details{}
|
||||
labels := classify.Labels{}
|
||||
|
|
|
@ -72,6 +72,10 @@ func IndexWorker(jobs <-chan IndexJob) {
|
|||
|
||||
log.Infof("index: %s main %s file %s", res, f.FileType(), txt.Quote(f.RelativeName(ind.originalsPath())))
|
||||
|
||||
if !res.Success() {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, f := range related.Files {
|
||||
if done[f.FileName()] {
|
||||
continue
|
||||
|
|
|
@ -37,8 +37,17 @@ func PhotoSearch(f form.PhotoSearch) (results PhotoResults, count int, err error
|
|||
Joins("JOIN files ON photos.id = files.photo_id AND files.file_missing = 0 AND files.deleted_at IS NULL").
|
||||
Joins("JOIN cameras ON photos.camera_id = cameras.id").
|
||||
Joins("JOIN lenses ON photos.lens_id = lenses.id").
|
||||
Joins("JOIN places ON photos.place_id = places.id").
|
||||
Where("files.file_type = 'jpg' OR files.file_video = 1")
|
||||
Joins("JOIN places ON photos.place_id = places.id")
|
||||
|
||||
if !f.Hidden {
|
||||
s = s.Where("files.file_type = 'jpg' OR files.file_video = 1")
|
||||
|
||||
if f.Error {
|
||||
s = s.Where("files.file_error <> ''")
|
||||
} else {
|
||||
s = s.Where("files.file_error = ''")
|
||||
}
|
||||
}
|
||||
|
||||
// Shortcut for known photo ids.
|
||||
if f.ID != "" {
|
||||
|
@ -148,12 +157,6 @@ func PhotoSearch(f form.PhotoSearch) (results PhotoResults, count int, err error
|
|||
}
|
||||
|
||||
// Filter by additional flags and metadata.
|
||||
if f.Error {
|
||||
s = s.Where("files.file_error <> ''")
|
||||
} else {
|
||||
s = s.Where("files.file_error = ''")
|
||||
}
|
||||
|
||||
if f.Camera > 0 {
|
||||
s = s.Where("photos.camera_id = ?", f.Camera)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue