filter: Make --files-from traverse as before unless --no-traverse is set

In c5ac96e9e7 we made --files-from only read the objects specified and
don't scan directories.

This caused problems with Google drive (very very slow) and B2
(excessive API consumption) so it was decided to make the old
behaviour (traversing the directories) the default with --files-from
and use the existing --no-traverse flag (which has exactly the right
semantics) to enable the new non scanning behaviour.

See: https://forum.rclone.org/t/using-files-from-with-drive-hammers-the-api/8726

Fixes #3102 Fixes #3095
This commit is contained in:
Nick Craig-Wood
2019-02-13 17:14:51 +00:00
parent b05da61c82
commit a28239f005
4 changed files with 32 additions and 10 deletions

View File

@ -117,7 +117,7 @@ func TestCopyWithDepth(t *testing.T) {
}
// Test copy with files from
func TestCopyWithFilesFrom(t *testing.T) {
func testCopyWithFilesFrom(t *testing.T, noTraverse bool) {
r := fstest.NewRun(t)
defer r.Finalise()
file1 := r.WriteFile("potato2", "hello world", t1)
@ -131,9 +131,12 @@ func TestCopyWithFilesFrom(t *testing.T) {
// Monkey patch the active filter
oldFilter := filter.Active
oldNoTraverse := fs.Config.NoTraverse
filter.Active = f
fs.Config.NoTraverse = noTraverse
unpatch := func() {
filter.Active = oldFilter
fs.Config.NoTraverse = oldNoTraverse
}
defer unpatch()
@ -144,6 +147,8 @@ func TestCopyWithFilesFrom(t *testing.T) {
fstest.CheckItems(t, r.Flocal, file1, file2)
fstest.CheckItems(t, r.Fremote, file1)
}
func TestCopyWithFilesFrom(t *testing.T) { testCopyWithFilesFrom(t, false) }
func TestCopyWithFilesFromAndNoTraverse(t *testing.T) { testCopyWithFilesFrom(t, true) }
// Test copy empty directories
func TestCopyEmptyDirectories(t *testing.T) {