Skip to content

Commit 32046d2

Browse files
committed
case publish error catch
1 parent e9e6a42 commit 32046d2

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

LearningHub.Nhs.WebUI/Controllers/Api/ContributeController.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,18 @@ public async Task<ActionResult> PublishResourceVersionAsync([FromBody] PublishVi
349349
{
350350
if (associatedResource.ResourceType != ResourceTypeEnum.Scorm && associatedResource.ResourceType != ResourceTypeEnum.Html)
351351
{
352+
try
353+
{
352354
var obsoleteFiles = await this.resourceService.GetObsoleteResourceFile(publishViewModel.ResourceVersionId);
353355
if (obsoleteFiles != null && obsoleteFiles.Any())
354356
{
355-
await this.fileService.PurgeResourceFile(null, obsoleteFiles);
357+
_ = Task.Run(async () => { await this.fileService.PurgeResourceFile(null, obsoleteFiles); });
356358
}
359+
}
360+
catch (Exception ex)
361+
{
362+
this.Logger.LogError($"File Archive Error: {ex.Message}", $"ResourceVersionId -{publishViewModel.ResourceVersionId}");
363+
}
357364
}
358365
}
359366

@@ -707,8 +714,8 @@ private async Task RemoveBlockCollectionFiles(int resourceVersionId, BlockCollec
707714
{
708715
foreach (var oldblock in existingImages)
709716
{
710-
var entry = newBlocks.FirstOrDefault(x => x.BlockType == BlockType.Media && x.MediaBlock != null && x.MediaBlock.MediaType == MediaType.Image && x.MediaBlock.Image != null && (x.MediaBlock?.Image?.File?.FileId == oldblock.MediaBlock?.Image?.File?.FileId || x.MediaBlock?.Image?.File?.FilePath == oldblock.MediaBlock?.Image?.File?.FilePath));
711-
if (entry == null)
717+
var entry = newBlocks.FirstOrDefault(x => x.BlockType == BlockType.Media && x.MediaBlock != null && x.MediaBlock.MediaType == MediaType.Image && x.MediaBlock.Image != null && (x.MediaBlock?.Image?.File?.FileId == oldblock.MediaBlock?.Image?.File?.FileId || x.MediaBlock?.Image?.File?.FilePath == oldblock.MediaBlock?.Image?.File?.FilePath));
718+
if (entry == null)
712719
{
713720
filePaths.Add(oldblock?.MediaBlock?.Image?.File?.FilePath);
714721
}
@@ -790,8 +797,10 @@ private async Task RemoveBlockCollectionFiles(int resourceVersionId, BlockCollec
790797
_ = Task.Run(async () => { await this.fileService.PurgeResourceFile(null, deleteList); });
791798
}
792799
}
793-
catch
800+
catch (Exception ex)
794801
{
802+
var param = new object[] { resourceVersionId, existingResource, newResource };
803+
this.Logger.LogError($"BlockCollection Archive Error: {ex.Message}", param);
795804
}
796805
}
797806

0 commit comments

Comments
 (0)