From 45db2fe79b637b2d7b3e0da02948771d9a68cbab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=A4felfinger?= Date: Wed, 27 Feb 2019 22:13:23 +0100 Subject: [PATCH] made app context internal to the app parts --- internal/app/app.go | 8 ++++---- internal/app/category.go | 6 +++--- internal/app/images.go | 2 +- internal/app/types.go | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/app/app.go b/internal/app/app.go index f74af7e..bef0f95 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -52,7 +52,7 @@ func Run() { _ = authentication.Logout(context.Piwigo) } -func configureContext() (*AppContext, error) { +func configureContext() (*appContext, error) { logrus.Infoln("Preparing application context and configuration") if *piwigoUrl == "" { @@ -67,7 +67,7 @@ func configureContext() (*AppContext, error) { return nil, errors.New("missing piwigo password!") } - context := new(AppContext) + context := new(appContext) context.LocalRootPath = *imagesRootPath context.Piwigo = new(piwigo.PiwigoContext) context.Piwigo.Url = fmt.Sprintf("%s/ws.php?format=json", *piwigoUrl) @@ -77,7 +77,7 @@ func configureContext() (*AppContext, error) { return context, nil } -func loginToPiwigoAndConfigureContext(context *AppContext) error { +func loginToPiwigoAndConfigureContext(context *appContext) error { logrus.Infoln("Logging in to piwigo and getting chunk size configuration for uploads") err := authentication.Login(context.Piwigo) if err != nil { @@ -86,7 +86,7 @@ func loginToPiwigoAndConfigureContext(context *AppContext) error { return initializeUploadChunkSize(context) } -func initializeUploadChunkSize(context *AppContext) error { +func initializeUploadChunkSize(context *appContext) error { userStatus, err := authentication.GetStatus(context.Piwigo) if err != nil { return err diff --git a/internal/app/category.go b/internal/app/category.go index 40f3a63..2a9765f 100644 --- a/internal/app/category.go +++ b/internal/app/category.go @@ -10,13 +10,13 @@ import ( "sort" ) -func getAllCategoriesFromServer(context *AppContext) (map[string]*category.PiwigoCategory, error) { +func getAllCategoriesFromServer(context *appContext) (map[string]*category.PiwigoCategory, error) { logrus.Debugln("Starting GetAllCategories") categories, err := category.GetAllCategories(context.Piwigo) return categories, err } -func synchronizeCategories(context *AppContext, filesystemNodes map[string]*localFileStructure.FilesystemNode, existingCategories map[string]*category.PiwigoCategory) error { +func synchronizeCategories(context *appContext, filesystemNodes map[string]*localFileStructure.FilesystemNode, existingCategories map[string]*category.PiwigoCategory) error { logrus.Infoln("Synchronizing categories...") missingCategories := findMissingCategories(filesystemNodes, existingCategories) @@ -50,7 +50,7 @@ func findMissingCategories(fileSystem map[string]*localFileStructure.FilesystemN return missingCategories } -func createMissingCategories(context *AppContext, missingCategories []string, existingCategories map[string]*category.PiwigoCategory) error { +func createMissingCategories(context *appContext, missingCategories []string, existingCategories map[string]*category.PiwigoCategory) error { // we sort them to make sure the categories gets created // in the right order and we have the parent available while creating the children sort.Strings(missingCategories) diff --git a/internal/app/images.go b/internal/app/images.go index c528e0e..75d3c5b 100644 --- a/internal/app/images.go +++ b/internal/app/images.go @@ -7,7 +7,7 @@ import ( "haefelfinger.net/piwigo/DirectoriesToAlbums/internal/pkg/piwigo/category" ) -func synchronizeImages(context *AppContext, fileSystem map[string]*localFileStructure.FilesystemNode, existingCategories map[string]*category.PiwigoCategory) error { +func synchronizeImages(context *appContext, fileSystem map[string]*localFileStructure.FilesystemNode, existingCategories map[string]*category.PiwigoCategory) error { imageFiles, err := localFileStructure.GetImageList(fileSystem) if err != nil { diff --git a/internal/app/types.go b/internal/app/types.go index 9e05b6e..25dc05c 100644 --- a/internal/app/types.go +++ b/internal/app/types.go @@ -4,7 +4,7 @@ import ( "haefelfinger.net/piwigo/DirectoriesToAlbums/internal/pkg/piwigo" ) -type AppContext struct { +type appContext struct { Piwigo *piwigo.PiwigoContext SessionId string LocalRootPath string