Demo: Restore albums from YAML backups

This commit is contained in:
Michael Mayer 2021-02-22 21:21:14 +01:00
parent 4c5a730da4
commit ac5a9d5ee4
2 changed files with 5 additions and 2 deletions

View file

@ -27,6 +27,7 @@ ENV PHOTOPRISM_JPEG_QUALITY 95
ENV PHOTOPRISM_SITE_CAPTION "Demo"
# Import example photos
RUN photoprism restore -a
RUN photoprism index
RUN photoprism moments

View file

@ -80,10 +80,12 @@ func RestoreAlbums(force bool) (count int, result error) {
if err := a.LoadFromYaml(fileName); err != nil {
log.Errorf("restore: %s in %s", err, txt.Quote(filepath.Base(fileName)))
result = err
} else if len(a.Photos) == 0 && a.AlbumFilter == "" {
} else if a.AlbumType == "" || len(a.Photos) == 0 && a.AlbumFilter == "" {
log.Debugf("restore: skipping %s", txt.Quote(filepath.Base(fileName)))
} else if err := a.Find(); err == nil {
log.Infof("%s: %s already exists", a.AlbumType, txt.Quote(a.AlbumTitle))
} else if err := a.Create(); err != nil {
log.Warnf("%s: %s already exists", a.AlbumType, txt.Quote(a.AlbumTitle))
log.Errorf("%s: %s in %s", a.AlbumType, err, txt.Quote(filepath.Base(fileName)))
} else {
count++
}