1
mirror of https://github.com/rclone/rclone synced 2024-11-17 17:30:37 +01:00

Warn the user about files with same name but different case

Relates to #107 & #119.
This commit is contained in:
Nick Craig-Wood 2016-01-23 20:16:47 +00:00
parent 74a71f7824
commit 8c211fc8df

View File

@ -7,9 +7,12 @@ import (
"io"
"mime"
"path"
"strings"
"sync"
"sync/atomic"
"time"
"golang.org/x/text/unicode/norm"
)
// CalculateModifyWindow works out modify window for Fses passed in -
@ -407,19 +410,24 @@ func DeleteFiles(toBeDeleted ObjectsChan) {
// otherwise only files passing the filter will be added.
func readFilesMap(fs Fs, includeAll bool) map[string]Object {
files := make(map[string]Object)
normalised := make(map[string]struct{})
for o := range fs.List() {
remote := o.Remote()
normalisedRemote := strings.ToLower(norm.NFC.String(remote))
if _, ok := files[remote]; !ok {
// Make sure we don't delete excluded files if not required
if includeAll || Config.Filter.IncludeObject(o) {
files[remote] = o
if _, ok := normalised[normalisedRemote]; ok {
Log(o, "Warning: File found with same name but different case on %v", o.Fs())
}
} else {
Debug(o, "Excluded from sync (and deletion)")
}
} else {
Log(o, "Duplicate file detected")
}
normalised[normalisedRemote] = struct{}{}
}
return files
}