diff options
| author | Niels van Velzen <nielsvanvelzen@users.noreply.github.com> | 2024-04-30 13:41:13 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-30 13:41:13 +0200 |
| commit | 0b1535277178429916bbd59d67fa3b19c6768bb3 (patch) | |
| tree | a585cea21f50c3b6708b4d8e9fe7fd3c355b1461 /Jellyfin.Api/Controllers/DynamicHlsController.cs | |
| parent | 2cbef3aa383b05e51b76fb399a2a2fded56518e5 (diff) | |
| parent | 2459b7e62e9c5da75963323ec3c6e43b8568370f (diff) | |
Merge pull request #11361 from Bond-009/nope
Properly await Task.Delay()
Diffstat (limited to 'Jellyfin.Api/Controllers/DynamicHlsController.cs')
| -rw-r--r-- | Jellyfin.Api/Controllers/DynamicHlsController.cs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Jellyfin.Api/Controllers/DynamicHlsController.cs b/Jellyfin.Api/Controllers/DynamicHlsController.cs index 24edd7958..68602c80d 100644 --- a/Jellyfin.Api/Controllers/DynamicHlsController.cs +++ b/Jellyfin.Api/Controllers/DynamicHlsController.cs @@ -1481,7 +1481,7 @@ public class DynamicHlsController : BaseJellyfinApiController if (currentTranscodingIndex.HasValue) { - DeleteLastFile(playlistPath, segmentExtension, 0); + await DeleteLastFile(playlistPath, segmentExtension, 0).ConfigureAwait(false); } streamingRequest.StartTimeTicks = streamingRequest.CurrentRuntimeTicks; @@ -2009,17 +2009,19 @@ public class DynamicHlsController : BaseJellyfinApiController } } - private void DeleteLastFile(string playlistPath, string segmentExtension, int retryCount) + private Task DeleteLastFile(string playlistPath, string segmentExtension, int retryCount) { var file = GetLastTranscodingFile(playlistPath, segmentExtension, _fileSystem); - if (file is not null) + if (file is null) { - DeleteFile(file.FullName, retryCount); + return Task.CompletedTask; } + + return DeleteFile(file.FullName, retryCount); } - private void DeleteFile(string path, int retryCount) + private async Task DeleteFile(string path, int retryCount) { if (retryCount >= 5) { @@ -2036,9 +2038,8 @@ public class DynamicHlsController : BaseJellyfinApiController { _logger.LogError(ex, "Error deleting partial stream file(s) {Path}", path); - var task = Task.Delay(100); - task.Wait(); - DeleteFile(path, retryCount + 1); + await Task.Delay(100).ConfigureAwait(false); + await DeleteFile(path, retryCount + 1).ConfigureAwait(false); } catch (Exception ex) { |
