mirror of
https://github.com/rclone/rclone.git
synced 2024-11-07 09:04:52 +01:00
dirtree: fix tests with -fast-list
In commit
da404dc0f2
sync,copy: Fix --fast-list --create-empty-src-dirs and --exclude
The fix caused DirTree.AddDir to be called with the root directory.
This in turn caused a spurious directory entry in the DirTree which
caused tests with the -fast-list flag to fail with directory not found
errors.
This commit is contained in:
parent
5db9a2f831
commit
7c1f2d7c84
@ -40,9 +40,12 @@ func (dt DirTree) Add(entry fs.DirEntry) {
|
||||
// this creates the directory itself if required
|
||||
// it doesn't create parents
|
||||
func (dt DirTree) AddDir(entry fs.DirEntry) {
|
||||
dirPath := entry.Remote()
|
||||
if dirPath == "" {
|
||||
return
|
||||
}
|
||||
dt.Add(entry)
|
||||
// create the directory itself if it doesn't exist already
|
||||
dirPath := entry.Remote()
|
||||
if _, ok := dt[dirPath]; !ok {
|
||||
dt[dirPath] = nil
|
||||
}
|
||||
|
@ -51,6 +51,14 @@ func TestDirTreeAddDir(t *testing.T) {
|
||||
dir/subdir/
|
||||
sausage/
|
||||
dir/subdir/sausage/
|
||||
`, dt.String())
|
||||
d = mockdir.New("")
|
||||
dt.AddDir(d)
|
||||
assert.Equal(t, `/
|
||||
potato/
|
||||
dir/subdir/
|
||||
sausage/
|
||||
dir/subdir/sausage/
|
||||
`, dt.String())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user