Răsfoiți Sursa

Add version to LocalIndexUpdate event.

Allows correlating LocalIndexUpdate events on one device with RemoteIndexUpdated on another to make sure the cluster has converged.
Jakob Borg 10 ani în urmă
părinte
comite
127b0c3332
1 a modificat fișierele cu 6 adăugiri și 3 ștergeri
  1. 6 3
      internal/model/model.go

+ 6 - 3
internal/model/model.go

@@ -1123,8 +1123,10 @@ func sendIndexTo(initial bool, minLocalVer int64, conn protocol.Connection, fold
 
 
 func (m *Model) updateLocals(folder string, fs []protocol.FileInfo) {
 func (m *Model) updateLocals(folder string, fs []protocol.FileInfo) {
 	m.fmut.RLock()
 	m.fmut.RLock()
-	m.folderFiles[folder].Update(protocol.LocalDeviceID, fs)
+	files := m.folderFiles[folder]
 	m.fmut.RUnlock()
 	m.fmut.RUnlock()
+	files.Update(protocol.LocalDeviceID, fs)
+
 	m.rvmut.Lock()
 	m.rvmut.Lock()
 	for _, f := range fs {
 	for _, f := range fs {
 		delete(m.reqValidationCache, folder+"/"+f.Name)
 		delete(m.reqValidationCache, folder+"/"+f.Name)
@@ -1132,8 +1134,9 @@ func (m *Model) updateLocals(folder string, fs []protocol.FileInfo) {
 	m.rvmut.Unlock()
 	m.rvmut.Unlock()
 
 
 	events.Default.Log(events.LocalIndexUpdated, map[string]interface{}{
 	events.Default.Log(events.LocalIndexUpdated, map[string]interface{}{
-		"folder": folder,
-		"items":  len(fs),
+		"folder":  folder,
+		"items":   len(fs),
+		"version": files.LocalVersion(protocol.LocalDeviceID),
 	})
 	})
 }
 }