mirror of https://github.com/rclone/rclone.git
googlephotos: make the start year configurable - fixes #3630
This commit is contained in:
parent
58ea15078f
commit
4c258787b5
|
@ -134,14 +134,20 @@ rclone mount needs to know the size of files in advance of reading
|
||||||
them, so setting this flag when using rclone mount is recommended if
|
them, so setting this flag when using rclone mount is recommended if
|
||||||
you want to read the media.`,
|
you want to read the media.`,
|
||||||
Advanced: true,
|
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 backend
|
// Options defines the configuration for this backend
|
||||||
type Options struct {
|
type Options struct {
|
||||||
ReadOnly bool `config:"read_only"`
|
ReadOnly bool `config:"read_only"`
|
||||||
ReadSize bool `config:"read_size"`
|
ReadSize bool `config:"read_size"`
|
||||||
|
StartYear int `config:"start_year"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fs represents a remote storage server
|
// Fs represents a remote storage server
|
||||||
|
@ -202,6 +208,11 @@ func (f *Fs) dirTime() time.Time {
|
||||||
return f.startTime
|
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 retry
|
// retryErrorCodes is a slice of error codes that we will retry
|
||||||
var retryErrorCodes = []int{
|
var retryErrorCodes = []int{
|
||||||
429, // Too Many Requests.
|
429, // Too Many Requests.
|
||||||
|
|
|
@ -23,6 +23,7 @@ type lister interface {
|
||||||
listAlbums(ctx context.Context, shared bool) (all *albums, err error)
|
listAlbums(ctx context.Context, shared bool) (all *albums, err error)
|
||||||
listUploads(ctx context.Context, dir string) (entries fs.DirEntries, err error)
|
listUploads(ctx context.Context, dir string) (entries fs.DirEntries, err error)
|
||||||
dirTime() time.Time
|
dirTime() time.Time
|
||||||
|
startYear() int
|
||||||
}
|
}
|
||||||
|
|
||||||
// dirPattern describes a single directory pattern
|
// 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 nil, "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the years from 2000 to today
|
// Return the years from startYear to today
|
||||||
// FIXME make configurable?
|
|
||||||
func years(ctx context.Context, f lister, prefix string, match []string) (entries fs.DirEntries, err error) {
|
func years(ctx context.Context, f lister, prefix string, match []string) (entries fs.DirEntries, err error) {
|
||||||
currentYear := f.dirTime().Year()
|
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()))
|
entries = append(entries, fs.NewDir(prefix+fmt.Sprint(year), f.dirTime()))
|
||||||
}
|
}
|
||||||
return entries, nil
|
return entries, nil
|
||||||
|
|
|
@ -59,6 +59,11 @@ func (f *testLister) dirTime() time.Time {
|
||||||
return startTime
|
return startTime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mock startYear for testing
|
||||||
|
func (f *testLister) startYear() int {
|
||||||
|
return 2000
|
||||||
|
}
|
||||||
|
|
||||||
func TestPatternMatch(t *testing.T) {
|
func TestPatternMatch(t *testing.T) {
|
||||||
for testNumber, test := range []struct {
|
for testNumber, test := range []struct {
|
||||||
// input
|
// input
|
||||||
|
|
Loading…
Reference in New Issue