瀏覽代碼

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

Simon Frei 5 年之前
父節點
當前提交
1a8c10a8d0
共有 3 個文件被更改,包括 4 次插入15 次删除
  1. 1 1
      lib/model/folder.go
  2. 0 1
      lib/model/folder_sendonly.go
  3. 3 13
      lib/model/folder_sendrecv.go

+ 1 - 1
lib/model/folder.go

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

+ 0 - 1
lib/model/folder_sendonly.go

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

+ 3 - 13
lib/model/folder_sendrecv.go

@@ -595,11 +595,9 @@ func (f *sendReceiveFolder) handleDir(file protocol.FileInfo, snap *db.Snapshot,
 		if !curFile.IsSymlink() && f.inConflict(curFile.Version, file.Version) {
 			// 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
-			// archiving. Also merge with the version vector we had, to indicate
-			// we have resolved the conflict.
+			// archiving.
 			// Symlinks aren't checked for conflicts.
 
-			file.Version = file.Version.Merge(curFile.Version)
 			err = f.inWritableDir(func(name string) error {
 				return f.moveForConflict(name, file.ModifiedBy.String(), scanChan)
 			}, 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) {
 		// 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
-		// archiving. Also merge with the version vector we had, to indicate
-		// we have resolved the conflict.
+		// archiving.
 		// Directories and symlinks aren't checked for conflicts.
 
-		file.Version = file.Version.Merge(curFile.Version)
 		return f.inWritableDir(func(name string) error {
 			return f.moveForConflict(name, file.ModifiedBy.String(), scanChan)
 		}, 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
 
-	// 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}
 }
 
@@ -1543,11 +1535,9 @@ func (f *sendReceiveFolder) performFinish(file, curFile protocol.FileInfo, hasCu
 		if !curFile.IsDirectory() && !curFile.IsSymlink() && f.inConflict(curFile.Version, file.Version) {
 			// 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
-			// archiving. Also merge with the version vector we had, to indicate
-			// we have resolved the conflict.
+			// archiving.
 			// Directories and symlinks aren't checked for conflicts.
 
-			file.Version = file.Version.Merge(curFile.Version)
 			err = f.inWritableDir(func(name string) error {
 				return f.moveForConflict(name, file.ModifiedBy.String(), scanChan)
 			}, curFile.Name)