started synchronization of piwigo ids and upload required
This commit is contained in:
parent
20eeba2615
commit
5166b0c6b8
@ -48,11 +48,16 @@ func Run() {
|
|||||||
logErrorAndExit(err, 6)
|
logErrorAndExit(err, 6)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = synchronizeImages(context.piwigo, context.dataStore, categories)
|
err = synchronizePiwigoMetadata(context.piwigo, context.dataStore)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logErrorAndExit(err, 7)
|
logErrorAndExit(err, 7)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = synchronizeImages(context.piwigo, context.dataStore, categories)
|
||||||
|
if err != nil {
|
||||||
|
logErrorAndExit(err, 8)
|
||||||
|
}
|
||||||
|
|
||||||
_ = piwigo.Logout(context.piwigo)
|
_ = piwigo.Logout(context.piwigo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/localFileStructure"
|
"git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/localFileStructure"
|
||||||
"git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/piwigo"
|
"git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/piwigo"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -18,6 +19,7 @@ func synchronizeLocalImageMetadata(metadataStorage ImageMetadataProvider, fileSy
|
|||||||
// - get file metadata from filesystem (date, filename, dir, modtime etc.)
|
// - get file metadata from filesystem (date, filename, dir, modtime etc.)
|
||||||
// - recalculate md5 sum if file changed referring to the stored record (reduces load after first calculation a lot)
|
// - recalculate md5 sum if file changed referring to the stored record (reduces load after first calculation a lot)
|
||||||
// - mark metadata as upload required if changed or new
|
// - mark metadata as upload required if changed or new
|
||||||
|
logrus.Debugf("Starting synchronizeLocalImageMetadata")
|
||||||
|
|
||||||
logrus.Info("Synchronizing local image metadata database with local available images")
|
logrus.Info("Synchronizing local image metadata database with local available images")
|
||||||
|
|
||||||
@ -58,12 +60,32 @@ func synchronizeLocalImageMetadata(metadataStorage ImageMetadataProvider, fileSy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logrus.Debugf("Finished synchronizeLocalImageMetadata")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// STEP 2 - get file states from piwigo (pwg.images.checkFiles)
|
func synchronizePiwigoMetadata(piwigo *piwigo.PiwigoContext, metadataStorage ImageMetadataProvider) error {
|
||||||
// - get upload status of md5 sum from piwigo for all marked to upload
|
// STEP 2 - get file states from piwigo (pwg.images.checkFiles)
|
||||||
// - check if category has to be assigned (image possibly added to two albums -> only uploaded once but assigned multiple times)
|
// - make bulk query possible
|
||||||
|
// - get upload status of md5 sum from piwigo for all marked to upload
|
||||||
|
// - build method to update database with new piwigoId by md5 sum
|
||||||
|
// - set UploadRequired to false and the returned piwigoid
|
||||||
|
// - check if category has to be assigned (image possibly added to two albums -> only uploaded once but assigned multiple times) -> implement later
|
||||||
|
|
||||||
|
logrus.Debugf("Starting synchronizePiwigoMetadata")
|
||||||
|
images, err := metadataStorage.GetImageMetadataToUpload()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logrus.Infof("Synchronizing metadata with existing Piwigo data...")
|
||||||
|
for img := range images {
|
||||||
|
logrus.Debug(img)
|
||||||
|
}
|
||||||
|
|
||||||
|
logrus.Debugf("Finished synchronizePiwigoMetadata")
|
||||||
|
return errors.New("N/A")
|
||||||
|
}
|
||||||
|
|
||||||
// STEP 3: Upload missing images
|
// STEP 3: Upload missing images
|
||||||
// - upload file in chunks
|
// - upload file in chunks
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/localFileStructure"
|
"git.haefelfinger.net/piwigo/PiwigoDirectoryUploader/internal/pkg/localFileStructure"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@ -160,6 +161,25 @@ func TestSynchronizeLocalImageMetadataShouldNotProcessDirectories(t *testing.T)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSynchronizePiwigoMetadata(t *testing.T) {
|
||||||
|
db := NewtestStore()
|
||||||
|
db.savedMetadata["2019/shooting1/abc.jpg"] = ImageMetaData{
|
||||||
|
Md5Sum: "2019/shooting1/abc.jpg",
|
||||||
|
RelativeImagePath: "2019/shooting1/abc.jpg",
|
||||||
|
UploadRequired: false,
|
||||||
|
LastChange: time.Date(2019, 01, 01, 00, 0, 0, 0, time.UTC),
|
||||||
|
Filename: "abc.jpg",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// execute the sync metadata based on the file system results
|
||||||
|
//err := synchronizeLocalImageMetadata( db)
|
||||||
|
//if err != nil {
|
||||||
|
// t.Error(err)
|
||||||
|
//}
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
|
||||||
// test metadata store to store save the metadat and simulate the database
|
// test metadata store to store save the metadat and simulate the database
|
||||||
type testStore struct {
|
type testStore struct {
|
||||||
savedMetadata map[string]ImageMetaData
|
savedMetadata map[string]ImageMetaData
|
||||||
@ -182,6 +202,10 @@ func (s *testStore) SaveImageMetadata(m ImageMetaData) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *testStore) GetImageMetadataToUpload() ([]*ImageMetaData, error) {
|
||||||
|
return nil, errors.New("N/A")
|
||||||
|
}
|
||||||
|
|
||||||
// to make the sync testable, we pass in a simple mock that returns the filepath as checksum
|
// to make the sync testable, we pass in a simple mock that returns the filepath as checksum
|
||||||
func testChecksumCalculator(file string) (string, error) {
|
func testChecksumCalculator(file string) (string, error) {
|
||||||
return file, nil
|
return file, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user