From cc778e56154ba8e1160b7dd33e3a322033712c0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=A4felfinger?= Date: Sat, 2 Mar 2019 00:32:15 +0100 Subject: [PATCH] added sort to populate by category not by random file order --- internal/app/images.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/app/images.go b/internal/app/images.go index 6e4976a..2a7657e 100644 --- a/internal/app/images.go +++ b/internal/app/images.go @@ -5,6 +5,7 @@ import ( "git.haefelfinger.net/piwigo/DirectoriesToAlbums/internal/pkg/piwigo/category" "git.haefelfinger.net/piwigo/DirectoriesToAlbums/internal/pkg/piwigo/picture" "github.com/sirupsen/logrus" + "sort" ) func synchronizeImages(context *appContext, fileSystem map[string]*localFileStructure.FilesystemNode, existingCategories map[string]*category.PiwigoCategory) error { @@ -58,6 +59,12 @@ func findMissingImages(context *appContext, imageFiles []*localFileStructure.Ima } func uploadImages(context *appContext, missingFiles []*localFileStructure.ImageNode, existingCategories map[string]*category.PiwigoCategory) error { + + // We sort the files by path to populate per category and not random by file + sort.Slice(missingFiles, func(i, j int) bool { + return missingFiles[i].Path < missingFiles[j].Path + }) + for _, file := range missingFiles { logrus.Infof("Uploading %s %s", file.CategoryName, file.Path) categoryId := existingCategories[file.CategoryName].Id