Skip to content

Commit

Permalink
Defer link import if the revision has multiple link updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Hjelm authored Dec 21, 2024
1 parent 5f19dc1 commit 6a2f92a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/WorkItemMigrator/WorkItemImport/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 6a2f92a

Please sign in to comment.