aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Drawing.Skia/SkiaEncoder.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.Drawing.Skia/SkiaEncoder.cs
parent5f52a58e785fa4ae06fa07a93b81c1e7547ac9f3 (diff)
Use null coalescing when possible
Diffstat (limited to 'Jellyfin.Drawing.Skia/SkiaEncoder.cs')
-rw-r--r--Jellyfin.Drawing.Skia/SkiaEncoder.cs21
1 files changed, 3 insertions, 18 deletions
diff --git a/Jellyfin.Drawing.Skia/SkiaEncoder.cs b/Jellyfin.Drawing.Skia/SkiaEncoder.cs
index 1570d247b..0c90d04a7 100644
--- a/Jellyfin.Drawing.Skia/SkiaEncoder.cs
+++ b/Jellyfin.Drawing.Skia/SkiaEncoder.cs
@@ -228,12 +228,7 @@ namespace Jellyfin.Drawing.Skia
}
var tempPath = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid() + Path.GetExtension(path));
- var directory = Path.GetDirectoryName(tempPath);
- if (directory == null)
- {
- throw new ResourceNotFoundException(nameof(directory));
- }
-
+ var directory = Path.GetDirectoryName(tempPath) ?? throw new ResourceNotFoundException(nameof(tempPath));
Directory.CreateDirectory(directory);
File.Copy(path, tempPath, true);
@@ -499,12 +494,7 @@ namespace Jellyfin.Drawing.Skia
// If all we're doing is resizing then we can stop now
if (!hasBackgroundColor && !hasForegroundColor && blur == 0 && !hasIndicator)
{
- var outputDirectory = Path.GetDirectoryName(outputPath);
- if (outputDirectory == null)
- {
- throw new ResourceNotFoundException(nameof(outputDirectory));
- }
-
+ var outputDirectory = Path.GetDirectoryName(outputPath) ?? throw new ResourceNotFoundException(nameof(outputPath));
Directory.CreateDirectory(outputDirectory);
using var outputStream = new SKFileWStream(outputPath);
using var pixmap = new SKPixmap(new SKImageInfo(width, height), resizedBitmap.GetPixels());
@@ -552,12 +542,7 @@ namespace Jellyfin.Drawing.Skia
DrawIndicator(canvas, width, height, options);
}
- 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);
using (var outputStream = new SKFileWStream(outputPath))
{