Skip to content

Commit 304e6e2

Browse files
Merge pull request #1044 from solidify/bugfix/try-catch-in-mark-attachment-as-processed
Add try-catch block in MarkAttachmentAsProcessed method to warn about already-added attachments
2 parents 62b378f + e989ed4 commit 304e6e2

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/WorkItemMigrator/Migration.Common/Journal.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using Migration.Common.Log;
2+
using System;
23
using System.Collections.Generic;
34
using System.IO;
45

@@ -78,8 +79,17 @@ private void WriteItem(string originId, int wiId, int rev)
7879

7980
public void MarkAttachmentAsProcessed(string attOriginId, string attWiId)
8081
{
81-
ProcessedAttachments.Add(attOriginId, attWiId);
82-
WriteAttachment(attOriginId, attWiId);
82+
try
83+
{
84+
ProcessedAttachments.Add(attOriginId, attWiId);
85+
WriteAttachment(attOriginId, attWiId);
86+
}
87+
catch(Exception ex)
88+
{
89+
Logger.Log(LogLevel.Warning, $"Failed to write attachment to the attachmentsJournal.txt file. An attachment with attOriginId={attOriginId} was already present in the dictionary. (attWiId={attWiId})");
90+
Logger.Log(LogLevel.Warning, ex.Message);
91+
}
92+
8393
}
8494

8595
private void WriteAttachment(string attOriginId, string attWiId)

0 commit comments

Comments
 (0)