diff options
| author | Bond_009 <bond.009@outlook.com> | 2023-10-10 00:18:50 +0200 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2023-10-10 00:18:50 +0200 |
| commit | 4757ce105bedb075c6663d92bc1e93f87c4779f2 (patch) | |
| tree | cb48f7ceb84f70cbf8d66ecda641fffa4968a016 /MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs | |
| parent | d5695efad9542c97080b8578379522ba12a1f824 (diff) | |
Use Process.WaitForExitAsync added in .NET 5
Diffstat (limited to 'MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs')
| -rw-r--r-- | MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs index 0ec0c84d4..299f294b2 100644 --- a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs +++ b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs @@ -174,22 +174,16 @@ namespace MediaBrowser.MediaEncoding.Attachments process.Start(); - var ranToCompletion = await ProcessExtensions.WaitForExitAsync(process, cancellationToken).ConfigureAwait(false); - - if (!ranToCompletion) + try { - try - { - _logger.LogWarning("Killing ffmpeg attachment extraction process"); - process.Kill(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Error killing attachment extraction process"); - } + await process.WaitForExitAsync(cancellationToken).ConfigureAwait(false); + exitCode = process.ExitCode; + } + catch (OperationCanceledException) + { + process.Kill(true); + exitCode = -1; } - - exitCode = ranToCompletion ? process.ExitCode : -1; } var failed = false; @@ -322,22 +316,16 @@ namespace MediaBrowser.MediaEncoding.Attachments process.Start(); - var ranToCompletion = await ProcessExtensions.WaitForExitAsync(process, cancellationToken).ConfigureAwait(false); - - if (!ranToCompletion) + try { - try - { - _logger.LogWarning("Killing ffmpeg attachment extraction process"); - process.Kill(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Error killing attachment extraction process"); - } + await process.WaitForExitAsync(cancellationToken).ConfigureAwait(false); + exitCode = process.ExitCode; + } + catch (OperationCanceledException) + { + process.Kill(true); + exitCode = -1; } - - exitCode = ranToCompletion ? process.ExitCode : -1; } var failed = false; |
