moved category to own package

This commit is contained in:
Philipp Häfelfinger 2019-04-02 21:58:54 +02:00
parent 58c1f8b9ff
commit 1bc176dd47
2 changed files with 6 additions and 5 deletions

View File

@ -7,6 +7,7 @@ package app
import (
"flag"
"git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/category"
"git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/images"
"git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/localFileStructure"
"github.com/sirupsen/logrus"
@ -39,12 +40,12 @@ func Run() {
logErrorAndExit(err, 3)
}
categories, err := getAllCategoriesFromServer(context.piwigo)
categories, err := category.GetAllCategoriesFromServer(context.piwigo)
if err != nil {
logErrorAndExit(err, 4)
}
err = synchronizeCategories(context.piwigo, filesystemNodes, categories)
err = category.SynchronizeCategories(context.piwigo, filesystemNodes, categories)
if err != nil {
logErrorAndExit(err, 5)
}

View File

@ -3,7 +3,7 @@
* This application is licensed under GPLv2. See the LICENSE file in the root directory of the project.
*/
package app
package category
import (
"errors"
@ -15,13 +15,13 @@ import (
"sort"
)
func getAllCategoriesFromServer(piwigoApi piwigo.PiwigoCategoryApi) (map[string]*piwigo.PiwigoCategory, error) {
func GetAllCategoriesFromServer(piwigoApi piwigo.PiwigoCategoryApi) (map[string]*piwigo.PiwigoCategory, error) {
logrus.Debugln("Starting GetAllCategories")
categories, err := piwigoApi.GetAllCategories()
return categories, err
}
func synchronizeCategories(piwigoApi piwigo.PiwigoCategoryApi, filesystemNodes map[string]*localFileStructure.FilesystemNode, existingCategories map[string]*piwigo.PiwigoCategory) error {
func SynchronizeCategories(piwigoApi piwigo.PiwigoCategoryApi, filesystemNodes map[string]*localFileStructure.FilesystemNode, existingCategories map[string]*piwigo.PiwigoCategory) error {
logrus.Infoln("Synchronizing categories...")
missingCategories := findMissingCategories(filesystemNodes, existingCategories)