Skip to content

Commit

Permalink
Fix/tfs attachment enricher unable to export (#2008)
Browse files Browse the repository at this point in the history
From: @jacobmalliet

Resolves an issue with the `TfsAttachmentEnricher` where `_server`
instance was always `null`. This seemingly occurred because of a
duplicate `WorkItemServer` instance variable `_workItemServer`.

After attempting to use `workItemServer` instead, I found that it was
also not being set properly because of a null comparison being done
incorrectly.

This change removes the duplicate `WorkItemServer` variable and properly
initializes the `_workItemServer` before exporting attachments.

First time contributing so let me know if you need anything else changed
here.
  • Loading branch information
MrHinsh authored Mar 26, 2024
2 parents ba26b5c + dbf329c commit 15d98ab
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ namespace MigrationTools.ProcessorEnrichers
{
public class TfsAttachmentEnricher : WorkItemProcessorEnricher, IAttachmentMigrationEnricher
{
private WorkItemServer _server;
private string _exportWiPath;
private TfsAttachmentEnricherOptions _options;
private WorkItemServer _workItemServer;
Expand Down Expand Up @@ -116,7 +115,7 @@ private string ExportAttachment(WorkItem wi, Attachment wia, string exportpath)
Log.LogDebug(string.Format("...downloading {0} to {1}", fname, exportpath));
try
{
var fileLocation = _server.DownloadFile(wia.Id);
var fileLocation = _workItemServer.DownloadFile(wia.Id);
File.Copy(fileLocation, fpath, true);
}
catch (Exception ex)
Expand Down Expand Up @@ -178,7 +177,7 @@ public string GetSafeFilename(string filename)

private void SetupWorkItemServer()
{
if (_workItemServer != null)
if (_workItemServer == null)
{
IMigrationEngine engine = Services.GetRequiredService<IMigrationEngine>();
_workItemServer = engine.Source.GetService<WorkItemServer>();
Expand Down

0 comments on commit 15d98ab

Please sign in to comment.