lib/model: Use winning version instead of merge on conflict (#6995)

This commit is contained in:
Simon Frei 2020-10-19 08:53:19 +02:00 committed by GitHub
parent 01a7ef3b0f
commit 1a8c10a8d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 15 deletions

View File

@ -488,7 +488,7 @@ func (f *folder) scanSubdirs(subDirs []string) error {
case !ok: case !ok:
case gf.IsEquivalentOptional(fi, f.modTimeWindow, false, false, protocol.FlagLocalReceiveOnly): case gf.IsEquivalentOptional(fi, f.modTimeWindow, false, false, protocol.FlagLocalReceiveOnly):
// What we have locally is equivalent to the global file. // What we have locally is equivalent to the global file.
fi.Version = fi.Version.Merge(gf.Version) fi.Version = gf.Version
fallthrough fallthrough
case fi.IsDeleted() && (gf.IsReceiveOnlyChanged() || gf.IsDeleted()): case fi.IsDeleted() && (gf.IsReceiveOnlyChanged() || gf.IsDeleted()):
// Our item is deleted and the global item is our own // Our item is deleted and the global item is our own

View File

@ -75,7 +75,6 @@ func (f *sendOnlyFolder) pull() bool {
return true return true
} }
file.Version = file.Version.Merge(curFile.Version)
batch = append(batch, file) batch = append(batch, file)
batchSizeBytes += file.ProtoSize() batchSizeBytes += file.ProtoSize()
l.Debugln(f, "Merging versions of identical file", file) l.Debugln(f, "Merging versions of identical file", file)

View File

@ -595,11 +595,9 @@ func (f *sendReceiveFolder) handleDir(file protocol.FileInfo, snap *db.Snapshot,
if !curFile.IsSymlink() && f.inConflict(curFile.Version, file.Version) { if !curFile.IsSymlink() && f.inConflict(curFile.Version, file.Version) {
// The new file has been changed in conflict with the existing one. We // The new file has been changed in conflict with the existing one. We
// should file it away as a conflict instead of just removing or // should file it away as a conflict instead of just removing or
// archiving. Also merge with the version vector we had, to indicate // archiving.
// we have resolved the conflict.
// Symlinks aren't checked for conflicts. // Symlinks aren't checked for conflicts.
file.Version = file.Version.Merge(curFile.Version)
err = f.inWritableDir(func(name string) error { err = f.inWritableDir(func(name string) error {
return f.moveForConflict(name, file.ModifiedBy.String(), scanChan) return f.moveForConflict(name, file.ModifiedBy.String(), scanChan)
}, curFile.Name) }, curFile.Name)
@ -773,11 +771,9 @@ func (f *sendReceiveFolder) handleSymlinkCheckExisting(file protocol.FileInfo, s
if !curFile.IsDirectory() && !curFile.IsSymlink() && f.inConflict(curFile.Version, file.Version) { if !curFile.IsDirectory() && !curFile.IsSymlink() && f.inConflict(curFile.Version, file.Version) {
// The new file has been changed in conflict with the existing one. We // The new file has been changed in conflict with the existing one. We
// should file it away as a conflict instead of just removing or // should file it away as a conflict instead of just removing or
// archiving. Also merge with the version vector we had, to indicate // archiving.
// we have resolved the conflict.
// Directories and symlinks aren't checked for conflicts. // Directories and symlinks aren't checked for conflicts.
file.Version = file.Version.Merge(curFile.Version)
return f.inWritableDir(func(name string) error { return f.inWritableDir(func(name string) error {
return f.moveForConflict(name, file.ModifiedBy.String(), scanChan) return f.moveForConflict(name, file.ModifiedBy.String(), scanChan)
}, curFile.Name) }, curFile.Name)
@ -1213,10 +1209,6 @@ func (f *sendReceiveFolder) shortcutFile(file, curFile protocol.FileInfo, dbUpda
f.fs.Chtimes(file.Name, file.ModTime(), file.ModTime()) // never fails f.fs.Chtimes(file.Name, file.ModTime(), file.ModTime()) // never fails
// This may have been a conflict. We should merge the version vectors so
// that our clock doesn't move backwards.
file.Version = file.Version.Merge(curFile.Version)
dbUpdateChan <- dbUpdateJob{file, dbUpdateShortcutFile} dbUpdateChan <- dbUpdateJob{file, dbUpdateShortcutFile}
} }
@ -1543,11 +1535,9 @@ func (f *sendReceiveFolder) performFinish(file, curFile protocol.FileInfo, hasCu
if !curFile.IsDirectory() && !curFile.IsSymlink() && f.inConflict(curFile.Version, file.Version) { if !curFile.IsDirectory() && !curFile.IsSymlink() && f.inConflict(curFile.Version, file.Version) {
// The new file has been changed in conflict with the existing one. We // The new file has been changed in conflict with the existing one. We
// should file it away as a conflict instead of just removing or // should file it away as a conflict instead of just removing or
// archiving. Also merge with the version vector we had, to indicate // archiving.
// we have resolved the conflict.
// Directories and symlinks aren't checked for conflicts. // Directories and symlinks aren't checked for conflicts.
file.Version = file.Version.Merge(curFile.Version)
err = f.inWritableDir(func(name string) error { err = f.inWritableDir(func(name string) error {
return f.moveForConflict(name, file.ModifiedBy.String(), scanChan) return f.moveForConflict(name, file.ModifiedBy.String(), scanChan)
}, curFile.Name) }, curFile.Name)