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.
This commit is contained in:
parent
8524afa9ce
commit
fe6c9aa4da
1 changed files with 6 additions and 0 deletions
|
@ -29,6 +29,7 @@ import (
|
||||||
"github.com/rclone/rclone/fs/fspath"
|
"github.com/rclone/rclone/fs/fspath"
|
||||||
"github.com/rclone/rclone/fs/hash"
|
"github.com/rclone/rclone/fs/hash"
|
||||||
"github.com/rclone/rclone/fs/operations"
|
"github.com/rclone/rclone/fs/operations"
|
||||||
|
"github.com/rclone/rclone/lib/encoder"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Chunker's composite files have one or more chunks
|
// 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 {
|
if caseInsensitive {
|
||||||
sameMain = strings.EqualFold(mainRemote, remote)
|
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 {
|
} else {
|
||||||
sameMain = mainRemote == remote
|
sameMain = mainRemote == remote
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue