From 6a2f92acc1a6d603f9648bf923794bda222e5c14 Mon Sep 17 00:00:00 2001 From: Alexander Hjelm Date: Sat, 21 Dec 2024 13:40:59 +0100 Subject: [PATCH] Defer link import if the revision has multiple link updates --- src/WorkItemMigrator/WorkItemImport/Agent.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/WorkItemMigrator/WorkItemImport/Agent.cs b/src/WorkItemMigrator/WorkItemImport/Agent.cs index 9171b1c..b932190 100644 --- a/src/WorkItemMigrator/WorkItemImport/Agent.cs +++ b/src/WorkItemMigrator/WorkItemImport/Agent.cs @@ -664,8 +664,9 @@ private bool ApplyAndSaveLinks(WiRevision rev, WorkItem wi, Settings settings) saveLinkTimestamp = saveLinkTimestamp.AddMilliseconds(2); } - foreach (var link in rev.Links) + for (int i = 0; i < rev.Links.Count; i++) { + var link = rev.Links[i]; try { int sourceWiId = _context.Journal.GetMigratedId(link.SourceOriginId); @@ -684,6 +685,13 @@ private bool ApplyAndSaveLinks(WiRevision rev, WorkItem wi, Settings settings) continue; } + if (i > 0) + { + // If this has multiple link updates, defer each ubsequent link import by 2 miliseconds. + // Otherwise the Work Items API will send the response: "VS402625: Dates must be increasing with each revision" + saveLinkTimestamp = saveLinkTimestamp.AddMilliseconds(2); + } + if (link.Change == ReferenceChangeType.Added && !_witClientUtils.AddAndSaveLink(link, wi, settings, rev.Author, saveLinkTimestamp)) { success = false;