fixed messages and stop processing if no images are ready to process

This commit is contained in:
Philipp Häfelfinger 2019-03-20 00:31:23 +01:00
parent f40308e378
commit 28f7b6eaef

View File

@ -79,13 +79,18 @@ func synchronizePiwigoMetadata(piwigoCtx *piwigo.PiwigoContext, metadataStorage
// Check all images with upload required if they are really changed and need to be uploaded to the server. // Check all images with upload required if they are really changed and need to be uploaded to the server.
func checkPiwigoForChangedImages(provider ImageMetadataProvider, piwigoCtx *piwigo.PiwigoContext) error { func checkPiwigoForChangedImages(provider ImageMetadataProvider, piwigoCtx *piwigo.PiwigoContext) error {
logrus.Infof("checking for pending files that are already on piwigo and updating piwigoids...") logrus.Infof("Checking pending files if they really differ from the version in piwigo...")
images, err := provider.ImageMetadataToUpload() images, err := provider.ImageMetadataToUpload()
if err != nil { if err != nil {
return err return err
} }
if len(images) == 0 {
logrus.Info("There are no existing images to check for modification on the server.")
return nil
}
for _, img := range images { for _, img := range images {
if img.PiwigoId == 0 { if img.PiwigoId == 0 {
continue continue
@ -118,6 +123,11 @@ func updatePiwigoIdIfAlreadyUploaded(provider ImageMetadataProvider, piwigoCtx *
return err return err
} }
if len(images) == 0 {
logrus.Info("There are no existing images to check for modification on the server.")
return nil
}
logrus.Debugln("Preparing lookuplist for missing piwigo ids...") logrus.Debugln("Preparing lookuplist for missing piwigo ids...")
files := make([]string, 0, len(images)) files := make([]string, 0, len(images))
for _, img := range images { for _, img := range images {
@ -125,6 +135,7 @@ func updatePiwigoIdIfAlreadyUploaded(provider ImageMetadataProvider, piwigoCtx *
files = append(files, img.Md5Sum) files = append(files, img.Md5Sum)
} }
} }
missingResults, err := piwigoCtx.ImagesExistOnPiwigo(files) missingResults, err := piwigoCtx.ImagesExistOnPiwigo(files)
if err != nil { if err != nil {
return err return err