diff --git a/internal/app/images.go b/internal/app/images.go index 95fa300..8a79cf9 100644 --- a/internal/app/images.go +++ b/internal/app/images.go @@ -7,16 +7,35 @@ import ( "haefelfinger.net/piwigo/DirectoriesToAlbums/internal/pkg/piwigo/category" ) -func synchronizeImages(fileSystem map[string]*localFileStructure.FilesystemNode, existingCategories map[string]*category.PiwigoCategory) error { - findMissingImages() - uploadImages() +func synchronizeImages(context *AppContext, fileSystem map[string]*localFileStructure.FilesystemNode, existingCategories map[string]*category.PiwigoCategory) error { + + imageFiles := getImageList(fileSystem) + + missingFiles := findMissingImages(imageFiles) + uploadImages(missingFiles) + return errors.New("synchronizeImages: NOT IMPLEMENTED") } -func findMissingImages() { +func findMissingImages(imageFiles []string) []string { + logrus.Warnln("Finding missing images (NotImplemented)") + + return nil } -func uploadImages() { +func uploadImages(missingFiles []string) { logrus.Warnln("Uploading missing images (NotImplemented)") } + +func getImageList(fileSystem map[string]*localFileStructure.FilesystemNode) []string { + imageFiles := []string{} + + for _, file := range fileSystem { + if !file.IsDir { + imageFiles = append(imageFiles, file.Key) + } + } + + return imageFiles +} diff --git a/internal/pkg/piwigo/picture/query.go b/internal/pkg/piwigo/picture/query.go new file mode 100644 index 0000000..a07290e --- /dev/null +++ b/internal/pkg/piwigo/picture/query.go @@ -0,0 +1,22 @@ +package picture + +import ( + "github.com/sirupsen/logrus" + "haefelfinger.net/piwigo/DirectoriesToAlbums/internal/pkg/piwigo" +) + +func ImageUploadRequired(context *piwigo.PiwigoContext, files []string) (bool, error) { + + for file := range files { + logrus.Debug(file) + } + + /* + http://pictures.haefelfinger.net/ws.php?format=json +{ + "md5sum_list": "d327416a83452b91764ed2888a5630a3,6d5f122e2b98bc1a192850e89fc2ae8c,40bfe8dd8349ccdedd4a939f9191cafa" +} + */ + + return false, nil +} diff --git a/internal/pkg/piwigo/picture/types.go b/internal/pkg/piwigo/picture/types.go new file mode 100644 index 0000000..c51acd4 --- /dev/null +++ b/internal/pkg/piwigo/picture/types.go @@ -0,0 +1,11 @@ +package picture + +type uploadChunkResponse struct { + Status string `json:"stat"` + Result interface{} `json:"result"` +} + +type imageExistResponse struct { + Stat string `json:"stat"` + Result map[string]string `json:"result"` +} diff --git a/internal/pkg/piwigo/picture/upload.go b/internal/pkg/piwigo/picture/upload.go new file mode 100644 index 0000000..26eaa57 --- /dev/null +++ b/internal/pkg/piwigo/picture/upload.go @@ -0,0 +1,11 @@ +package picture + + +/* +http://pictures.haefelfinger.net/ws.php?format=json +{ + "data": "123456", + "original_sum": "1234567", + "position": "1" +} + */