"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
googlephotos: make the start year configurable - fixes #3630
Daven4c258787b57d
diff --git a/backend/googlephotos/googlephotos.go b/backend/googlephotos/googlephotos.goindex 4fa4b327d..292bb0974 100644--- a/backend/googlephotos/googlephotos.go+++ b/backend/googlephotos/googlephotos.go@@ -134,14 +134,20 @@ rclone mount needs to know the size of files in advance of readingthem, so setting this flag when using rclone mount is recommended ifyou want to read the media.`,Advanced: true,+ }, {+ Name: "start_year",+ Default: 2000,+ Help: `Year limits the photos to be downloaded to those which are uploaded after the given year`,+ Advanced: true,}},})}// Options defines the configuration for this backendtype Options struct {- ReadOnly bool `config:"read_only"`- ReadSize bool `config:"read_size"`+ ReadOnly bool `config:"read_only"`+ ReadSize bool `config:"read_size"`+ StartYear int `config:"start_year"`}// Fs represents a remote storage server@@ -202,6 +208,11 @@ func (f *Fs) dirTime() time.Time {return f.startTime}+// startYear returns the start year+func (f *Fs) startYear() int {+ return f.opt.StartYear+}+// retryErrorCodes is a slice of error codes that we will retryvar retryErrorCodes = []int{429, // Too Many Requests.diff --git a/backend/googlephotos/pattern.go b/backend/googlephotos/pattern.goindex 198a82c06..e54b7c4ab 100644--- a/backend/googlephotos/pattern.go+++ b/backend/googlephotos/pattern.go@@ -23,6 +23,7 @@ type lister interface {listAlbums(ctx context.Context, shared bool) (all *albums, err error)listUploads(ctx context.Context, dir string) (entries fs.DirEntries, err error)dirTime() time.Time+ startYear() int}// dirPattern describes a single directory pattern@@ -222,11 +223,10 @@ func (ds dirPatterns) match(root string, itemPath string, isFile bool) (match []return nil, "", nil}-// Return the years from 2000 to today-// FIXME make configurable?+// Return the years from startYear to todayfunc years(ctx context.Context, f lister, prefix string, match []string) (entries fs.DirEntries, err error) {currentYear := f.dirTime().Year()- for year := 2000; year <= currentYear; year++ {+ for year := f.startYear(); year <= currentYear; year++ {entries = append(entries, fs.NewDir(prefix+fmt.Sprint(year), f.dirTime()))}return entries, nildiff --git a/backend/googlephotos/pattern_test.go b/backend/googlephotos/pattern_test.goindex 2fc2648e1..f7aafdd3c 100644--- a/backend/googlephotos/pattern_test.go+++ b/backend/googlephotos/pattern_test.go@@ -59,6 +59,11 @@ func (f *testLister) dirTime() time.Time {return startTime}+// mock startYear for testing+func (f *testLister) startYear() int {+ return 2000+}+func TestPatternMatch(t *testing.T) {for testNumber, test := range []struct {// input