mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
vfs: add flag --vfs-case-insensitive for windows/macOS mounts
rclone mount when run on Windows & macOS will now default to `--vfs-case-insensitive`. This means that
This commit is contained in:
committed by
Nick Craig-Wood
parent
530ba66d35
commit
1c4e33d4ad
18
vfs/dir.go
18
vfs/dir.go
@@ -323,6 +323,8 @@ func (d *Dir) readDir() error {
|
||||
// stat a single item in the directory
|
||||
//
|
||||
// returns ENOENT if not found.
|
||||
// returns a custom error if directory on a case-insensitive file system
|
||||
// contains files with names that differ only by case.
|
||||
func (d *Dir) stat(leaf string) (Node, error) {
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
@@ -331,6 +333,22 @@ func (d *Dir) stat(leaf string) (Node, error) {
|
||||
return nil, err
|
||||
}
|
||||
item, ok := d.items[leaf]
|
||||
|
||||
if !ok && d.vfs.Opt.CaseInsensitive {
|
||||
leafLower := strings.ToLower(leaf)
|
||||
for name, node := range d.items {
|
||||
if strings.ToLower(name) == leafLower {
|
||||
if ok {
|
||||
// duplicate case insensitive match is an error
|
||||
return nil, errors.Errorf("duplicate filename %q detected with --vfs-case-insensitive set", leaf)
|
||||
}
|
||||
// found a case insenstive match
|
||||
ok = true
|
||||
item = node
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !ok {
|
||||
return nil, ENOENT
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user