lib/model: Handle filename conflicts on Windows.
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3810 LGTM: calmh
This commit is contained in:
committed by
Audrius Butkevicius
parent
bab7c8ebbf
commit
01e50eb3fa
@@ -435,6 +435,13 @@ func (f *sendReceiveFolder) pullerIteration(ignores *ignore.Matcher) int {
|
||||
continue
|
||||
}
|
||||
|
||||
// Verify that we handle the right thing and not something whose name
|
||||
// collides.
|
||||
if !osutil.CheckNameConflict(f.dir, fi.Name) {
|
||||
f.newError(fi.Name, errNameConflict)
|
||||
continue
|
||||
}
|
||||
|
||||
switch {
|
||||
case fi.IsDeleted():
|
||||
// A deleted file, directory or symlink
|
||||
@@ -524,6 +531,13 @@ nextFile:
|
||||
continue
|
||||
}
|
||||
|
||||
// Verify that we handle the right thing and not something whose name
|
||||
// collides.
|
||||
if !osutil.CheckNameConflict(f.dir, fi.Name) {
|
||||
f.newError(fi.Name, errNameConflict)
|
||||
continue
|
||||
}
|
||||
|
||||
// Check our list of files to be removed for a match, in which case
|
||||
// we can just do a rename instead.
|
||||
key := string(fi.Blocks[0].Hash)
|
||||
@@ -1273,6 +1287,16 @@ func (f *sendReceiveFolder) copierRoutine(in <-chan copyBlocksState, pullChan ch
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
// The following checks are racy
|
||||
if !osutil.IsDir(folderRoots[folder], filepath.Dir(file)) {
|
||||
return false
|
||||
}
|
||||
if !osutil.CheckNameConflict(folderRoots[folder], file) {
|
||||
return false
|
||||
}
|
||||
if info, err := osutil.Lstat(inFile); err != nil || !info.Mode().IsRegular() {
|
||||
return false
|
||||
}
|
||||
fd, err := os.Open(inFile)
|
||||
if err != nil {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user