From 5de96e076e7d7ad9489c327d8aeed3883003c3e9 Mon Sep 17 00:00:00 2001 From: da3dsoul Date: Wed, 20 Mar 2024 19:48:00 -0400 Subject: [PATCH] Handle Exceptions on Rename/Move --- Shoko.Server/Services/VideoLocal_PlaceService.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Shoko.Server/Services/VideoLocal_PlaceService.cs b/Shoko.Server/Services/VideoLocal_PlaceService.cs index 92d9baaba..d6bd70057 100644 --- a/Shoko.Server/Services/VideoLocal_PlaceService.cs +++ b/Shoko.Server/Services/VideoLocal_PlaceService.cs @@ -51,6 +51,11 @@ public void RenameAndMoveAsRequired(SVR_VideoLocal_Place place) var retryPolicy = Policy .HandleResult(a => a.CanRetry) + .Or(e => + { + _logger.LogError(e, "Error Renaming/Moving File"); + return false; + }) .WaitAndRetry(new[] { TimeSpan.FromMilliseconds((int)DelayInUse.First), @@ -61,12 +66,12 @@ public void RenameAndMoveAsRequired(SVR_VideoLocal_Place place) var result = retryPolicy.Execute(() => invert ? RenameIfRequired(place) : MoveFileIfRequired(place)); // Don't bother renaming if we couldn't move. It'll need user interaction - if (!result.IsSuccess) return; + if (!result?.IsSuccess ?? true) return; // Retry logic for the second attempt result = retryPolicy.Execute(() => invert ? MoveFileIfRequired(place) : RenameIfRequired(place)); - if (!result.IsSuccess) return; + if (!result?.IsSuccess ?? true) return; try {