made app context internal to the app parts
This commit is contained in:
parent
2808c85147
commit
45db2fe79b
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user