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

@ -180,11 +180,11 @@ func TestNewFilterIncludeFiles(t *testing.T) {
require.NoError(t, err)
err = f.AddFile("/file2.jpg")
require.NoError(t, err)
assert.Equal(t, filesMap{
assert.Equal(t, FilesMap{
"file1.jpg": {},
"file2.jpg": {},
}, f.files)
assert.Equal(t, filesMap{}, f.dirs)
assert.Equal(t, FilesMap{}, f.dirs)
testInclude(t, f, []includeTest{
{"file1.jpg", 0, 0, true},
{"file2.jpg", 1, 0, true},
@ -206,7 +206,7 @@ func TestNewFilterIncludeFilesDirs(t *testing.T) {
err = f.AddFile(path)
require.NoError(t, err)
}
assert.Equal(t, filesMap{
assert.Equal(t, FilesMap{
"path": {},
"path/to": {},
"path/to/dir": {},