From b310490fa5976b0f3e7b3ee9e323f88764687a5b Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 9 Jul 2022 21:17:47 +0100 Subject: [PATCH] union: fix multiple files being uploaded when roots don't exist See: https://forum.rclone.org/t/union-backend-copying-to-all-remotes-while-it-shouldnt/31781 --- backend/union/union.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/union/union.go b/backend/union/union.go index fc78e20c3..0e894a50b 100644 --- a/backend/union/union.go +++ b/backend/union/union.go @@ -169,7 +169,11 @@ func (f *Fs) mkdir(ctx context.Context, dir string) ([]*upstream.Fs, error) { if err != nil { return nil, err } - return upstreams, nil + // If created roots then choose one + if dir == "" { + upstreams, err = f.create(ctx, dir) + } + return upstreams, err } // Mkdir makes the root directory of the Fs object