aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Helpers/TranscodingJobHelper.cs
diff options
context:
space:
mode:
authorcrobibero <cody@robibe.ro>2020-11-13 11:24:46 -0700
committercrobibero <cody@robibe.ro>2020-11-13 11:24:46 -0700
commit95ebb9a55ace6c544fa7fa15d0a255a5cee752a8 (patch)
treef5ce2c6ea994d63712d45772ad712ac6bcf79ab6 /Jellyfin.Api/Helpers/TranscodingJobHelper.cs
parent5f52a58e785fa4ae06fa07a93b81c1e7547ac9f3 (diff)
Use null coalescing when possible
Diffstat (limited to 'Jellyfin.Api/Helpers/TranscodingJobHelper.cs')
-rw-r--r--Jellyfin.Api/Helpers/TranscodingJobHelper.cs14
1 files changed, 2 insertions, 12 deletions
diff --git a/Jellyfin.Api/Helpers/TranscodingJobHelper.cs b/Jellyfin.Api/Helpers/TranscodingJobHelper.cs
index 4ec0c576a..846624183 100644
--- a/Jellyfin.Api/Helpers/TranscodingJobHelper.cs
+++ b/Jellyfin.Api/Helpers/TranscodingJobHelper.cs
@@ -196,12 +196,7 @@ namespace Jellyfin.Api.Helpers
/// <param name="state">The state.</param>
private async void OnTranscodeKillTimerStopped(object? state)
{
- var job = (TranscodingJobDto?)state;
- if (job == null)
- {
- throw new ResourceNotFoundException(nameof(job));
- }
-
+ var job = state as TranscodingJobDto ?? throw new ResourceNotFoundException(nameof(state));
if (!job.HasExited && job.Type != TranscodingJobType.Progressive)
{
var timeSinceLastPing = (DateTime.UtcNow - job.LastPingDate).TotalMilliseconds;
@@ -494,12 +489,7 @@ namespace Jellyfin.Api.Helpers
CancellationTokenSource cancellationTokenSource,
string? workingDirectory = null)
{
- var directory = Path.GetDirectoryName(outputPath);
- if (directory == null)
- {
- throw new ResourceNotFoundException(nameof(directory));
- }
-
+ var directory = Path.GetDirectoryName(outputPath) ?? throw new ResourceNotFoundException(nameof(outputPath));
Directory.CreateDirectory(directory);
await AcquireResources(state, cancellationTokenSource).ConfigureAwait(false);