Skip to content

Commit ee95baa

Browse files
author
Michael Ganss
committed
Perform sync only if destination version is lower than source
1 parent bf4d0b6 commit ee95baa

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

SyncChanges/Synchronizer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public bool Sync()
112112
return !Error;
113113
}
114114

115-
private bool Sync(ReplicationSet replicationSet, IList<TableInfo> tables)
115+
private bool Sync(ReplicationSet replicationSet, IList<TableInfo> tables, long sourceVersion = -1)
116116
{
117117
Error = false;
118118

@@ -121,7 +121,7 @@ private bool Sync(ReplicationSet replicationSet, IList<TableInfo> tables)
121121
Log.Info($"Starting replication for replication set {replicationSet.Name}");
122122

123123
var destinationsByVersion = replicationSet.Destinations.GroupBy(d => GetCurrentVersion(d))
124-
.Where(d => d.Key >= 0).ToList();
124+
.Where(d => d.Key >= 0 && (sourceVersion < 0 || d.Key < sourceVersion)).ToList();
125125

126126
foreach (var destinations in destinationsByVersion)
127127
Replicate(replicationSet.Source, destinations, tables);
@@ -168,7 +168,7 @@ public void SyncLoop(CancellationToken token)
168168
Log.Info($"Current version of source in replication set {replicationSet.Name} has increased from {currentVersion} to {version}: Starting replication.");
169169

170170
var tables = Tables[i];
171-
var success = Sync(replicationSet, tables);
171+
var success = Sync(replicationSet, tables, version);
172172

173173
if (success) currentVersions[i] = version;
174174

0 commit comments

Comments
 (0)