From 1cb01e595d98acedc9b814f6410ec6ec5ef45903 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Sun, 24 Mar 2024 12:14:07 +0000 Subject: [PATCH] Update to now use values from `TfsAttachmentEnricherOptions` --- .../ProcessorEnrichers/TfsAttachmentEnricher.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/MigrationTools.Clients.AzureDevops.ObjectModel/ProcessorEnrichers/TfsAttachmentEnricher.cs b/src/MigrationTools.Clients.AzureDevops.ObjectModel/ProcessorEnrichers/TfsAttachmentEnricher.cs index bc9e15419..17122ae1a 100644 --- a/src/MigrationTools.Clients.AzureDevops.ObjectModel/ProcessorEnrichers/TfsAttachmentEnricher.cs +++ b/src/MigrationTools.Clients.AzureDevops.ObjectModel/ProcessorEnrichers/TfsAttachmentEnricher.cs @@ -20,9 +20,7 @@ namespace MigrationTools.ProcessorEnrichers public class TfsAttachmentEnricher : WorkItemProcessorEnricher, IAttachmentMigrationEnricher { private WorkItemServer _server; - private string _exportBasePath; private string _exportWiPath; - private int _maxAttachmentSize; private TfsAttachmentEnricherOptions _options; private WorkItemServer _workItemServer; @@ -30,7 +28,7 @@ public class TfsAttachmentEnricher : WorkItemProcessorEnricher, IAttachmentMigra public TfsAttachmentEnricher(IServiceProvider services, ILogger logger) : base(services, logger) { - + } public void ProcessAttachemnts(WorkItemData source, WorkItemData target, bool save = true) @@ -46,7 +44,7 @@ public void ProcessAttachemnts(WorkItemData source, WorkItemData target, bool sa throw new ArgumentNullException(nameof(target)); } Log.LogInformation("AttachmentMigrationEnricher: Migrating {AttachmentCount} attachemnts from {SourceWorkItemID} to {TargetWorkItemID}", source.ToWorkItem().Attachments.Count, source.Id, target.Id); - _exportWiPath = Path.Combine(_exportBasePath, source.ToWorkItem().Id.ToString()); + _exportWiPath = Path.Combine(Options.ExportBasePath, source.ToWorkItem().Id.ToString()); if (Directory.Exists(_exportWiPath)) { Directory.Delete(_exportWiPath, true); @@ -139,7 +137,7 @@ private void ImportAttachment(WorkItem targetWorkItem, Attachment wia, string fi SetupWorkItemServer(); var filename = Path.GetFileName(filepath); FileInfo fi = new FileInfo(filepath); - if (_maxAttachmentSize > fi.Length) + if (Options.MaxAttachmentSize > fi.Length) { string originalId = "[originalId:" + wia.Id + "]"; var attachments = targetWorkItem.Attachments.Cast(); @@ -169,7 +167,7 @@ private void ImportAttachment(WorkItem targetWorkItem, Attachment wia, string fi } else { - Log.LogWarning(" [SKIP] Attachment {filename} on Work Item {targetWorkItemId} is bigger than the limit of {maxAttachmentSize} bites for Azure DevOps.", filename, targetWorkItem.Id, _maxAttachmentSize); + Log.LogWarning(" [SKIP] Attachment {filename} on Work Item {targetWorkItemId} is bigger than the limit of {maxAttachmentSize} bites for Azure DevOps.", filename, targetWorkItem.Id, Options.MaxAttachmentSize); } }