From fe6c9aa4da0e4f30629edbad89f7e58c4fafb3fb Mon Sep 17 00:00:00 2001 From: nielash Date: Tue, 9 Apr 2024 21:01:32 -0400 Subject: [PATCH] chunker: fix case-insensitive comparison on local without metadata Before this change, chunker would erroneously consider two different paths to be equal if, due to special characters, they normalized to equal-folding strings in Standard Encoding, but not otherwise. This caused base objects to get moved when they should not have been. This change fixes the issue, which was discovered on the bisync integration tests. Ideally it should also be fixed when the base Fs is non-local, but there's not an easy way at the moment to reference the wrapped Fs's encoding, at least without breaking encapsulation. --- backend/chunker/chunker.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/chunker/chunker.go b/backend/chunker/chunker.go index fe0a55afd..fa5bb5987 100644 --- a/backend/chunker/chunker.go +++ b/backend/chunker/chunker.go @@ -29,6 +29,7 @@ import ( "github.com/rclone/rclone/fs/fspath" "github.com/rclone/rclone/fs/hash" "github.com/rclone/rclone/fs/operations" + "github.com/rclone/rclone/lib/encoder" ) // Chunker's composite files have one or more chunks @@ -963,6 +964,11 @@ func (f *Fs) scanObject(ctx context.Context, remote string, quickScan bool) (fs. } if caseInsensitive { sameMain = strings.EqualFold(mainRemote, remote) + if sameMain && f.base.Features().IsLocal { + // on local, make sure the EqualFold still holds true when accounting for encoding. + // sometimes paths with special characters will only normalize the same way in Standard Encoding. + sameMain = strings.EqualFold(encoder.OS.FromStandardPath(mainRemote), encoder.OS.FromStandardPath(remote)) + } } else { sameMain = mainRemote == remote }