1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-03 00:53:43 +00:00

Stop single file and --files-from operations iterating through the source bucket.

This works by making sure directory listings that use a filter only
iterate the files provided in the filter (if any).

Single file copies now don't iterate the source or destination
buckets.

Note that this could potentially slow down very long `--files-from`
lists - this is easy to fix (with another flag probably) if it causes
anyone a problem.

Fixes #610
Fixes #769
This commit is contained in:
Nick Craig-Wood
2016-10-07 11:39:39 +01:00
parent ec7cef98d8
commit d033e92234
5 changed files with 97 additions and 16 deletions

View File

@@ -94,8 +94,8 @@ func (rs *rules) len() int {
return len(rs.rules)
}
// filesMap describes the map of files to transfer
type filesMap map[string]struct{}
// FilesMap describes the map of files to transfer
type FilesMap map[string]struct{}
// Filter describes any filtering in operation
type Filter struct {
@@ -106,8 +106,8 @@ type Filter struct {
ModTimeTo time.Time
fileRules rules
dirRules rules
files filesMap // files if filesFrom
dirs filesMap // dirs from filesFrom
files FilesMap // files if filesFrom
dirs FilesMap // dirs from filesFrom
}
// We use time conventions
@@ -313,8 +313,8 @@ func (f *Filter) AddRule(rule string) error {
// AddFile adds a single file to the files from list
func (f *Filter) AddFile(file string) error {
if f.files == nil {
f.files = make(filesMap)
f.dirs = make(filesMap)
f.files = make(FilesMap)
f.dirs = make(FilesMap)
}
file = strings.Trim(file, "/")
f.files[file] = struct{}{}
@@ -332,6 +332,13 @@ func (f *Filter) AddFile(file string) error {
return nil
}
// Files returns all the files from the `--files-from` list
//
// It may be nil if the list is empty
func (f *Filter) Files() FilesMap {
return f.files
}
// Clear clears all the filter rules
func (f *Filter) Clear() {
f.fileRules.clear()