diff --git a/internal/app/app.go b/internal/app/app.go index 752fc2e..2e092d6 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -21,32 +21,32 @@ var ( func Run() { context, err := configureContext() if err != nil { - os.Exit(1) + logErrorAndExit(err, 1) } err = loginToPiwigoAndConfigureContext(context) if err != nil { - os.Exit(2) + logErrorAndExit(err, 2) } filesystemNodes, err := localFileStructure.ScanLocalFileStructure(context.LocalRootPath) if err != nil { - os.Exit(3) + logErrorAndExit(err, 3) } categories, err := getAllCategoriesFromServer(context) if err != nil { - os.Exit(4) + logErrorAndExit(err, 4) } err = synchronizeCategories(filesystemNodes, categories) if err != nil { - os.Exit(5) + logErrorAndExit(err, 5) } err = synchronizeImages() if err != nil { - os.Exit(6) + logErrorAndExit(err, 6) } _ = authentication.Logout(context.Piwigo) @@ -95,3 +95,8 @@ func initializeUploadChunkSize(context *AppContext) error { logrus.Debugln(context.ChunkSizeBytes) return nil } + +func logErrorAndExit(err error, exitCode int) { + logrus.Errorln(err) + os.Exit(exitCode) +} diff --git a/internal/app/category.go b/internal/app/category.go index c1eac45..d5d0e4e 100644 --- a/internal/app/category.go +++ b/internal/app/category.go @@ -1,6 +1,7 @@ package app import ( + "errors" "github.com/sirupsen/logrus" "haefelfinger.net/piwigo/DirectoriesToAlbums/internal/pkg/localFileStructure" "haefelfinger.net/piwigo/DirectoriesToAlbums/internal/pkg/piwigo/category" @@ -48,10 +49,20 @@ func createMissingCategories(missingCategories []string, existingCategories map[ // in the right order and we have the parent available while creating the children sort.Strings(missingCategories) - logrus.Warnln("Creating missing albums (NotImplemented)") for _, c := range missingCategories { - logrus.Debug(c) + logrus.Infof("Creating category %s",c) + + // create category on piwigo + + // build new map entry + + // get parent entry by path + // set parent entry id + + // calculate new map key + // add to existing map + } - return nil + return errors.New("NOT IMPLEMENTED") } diff --git a/internal/app/images.go b/internal/app/images.go index fafe1c1..7134189 100644 --- a/internal/app/images.go +++ b/internal/app/images.go @@ -1,11 +1,14 @@ package app -import "github.com/sirupsen/logrus" +import ( + "errors" + "github.com/sirupsen/logrus" +) func synchronizeImages() error { findMissingImages() uploadImages() - return nil + return errors.New("NOT IMPLEMENTED") } func findMissingImages() {