From 86ee51321c0cb326b9b94b59761d6c46678e0a2c Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Thu, 14 Jul 2022 17:48:58 +0200 Subject: [PATCH] Folders: Show no error if fs.Dirs returns at least one result Signed-off-by: Michael Mayer --- internal/query/folders.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/query/folders.go b/internal/query/folders.go index fdceb9d4e..18eccc5a8 100644 --- a/internal/query/folders.go +++ b/internal/query/folders.go @@ -8,12 +8,18 @@ import ( "github.com/photoprism/photoprism/pkg/fs" ) -// FoldersByPath returns a slice of folders in a given directory incl sub directories in recursive mode. +// FoldersByPath returns a slice of folders in a given directory incl sub-folders in recursive mode. func FoldersByPath(rootName, rootPath, path string, recursive bool) (folders entity.Folders, err error) { dirs, err := fs.Dirs(filepath.Join(rootPath, path), recursive, true) + // Failed? if err != nil { - return folders, err + if len(dirs) == 0 { + return folders, err + } else { + // At least one folder found. + log.Infof("folders: %s", err) + } } folders = make(entity.Folders, len(dirs)) @@ -21,7 +27,7 @@ func FoldersByPath(rootName, rootPath, path string, recursive bool) (folders ent for i, dir := range dirs { newFolder := entity.NewFolder(rootName, filepath.Join(path, dir), fs.BirthTime(filepath.Join(rootPath, dir))) - if err := newFolder.Create(); err == nil { + if err = newFolder.Create(); err == nil { folders[i] = newFolder } else if folder := entity.FindFolder(rootName, filepath.Join(path, dir)); folder != nil { folders[i] = *folder