aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrobibero <cody@robibe.ro>2020-11-13 08:34:34 -0700
committercrobibero <cody@robibe.ro>2020-11-13 08:34:34 -0700
commita02514a114dbca0b966578759fb347f8e6174c2b (patch)
tree58282bebe01ba4c87aa4cb6bc4ed44a80040b076
parent57b1e93411a19f1f6ea95131bdbeea4f9765df89 (diff)
Fix nullability errors in Jellyfin.Drawing.Skia
-rw-r--r--Jellyfin.Drawing.Skia/SkiaEncoder.cs23
1 files changed, 20 insertions, 3 deletions
diff --git a/Jellyfin.Drawing.Skia/SkiaEncoder.cs b/Jellyfin.Drawing.Skia/SkiaEncoder.cs
index 6a9dbdae4..ad066c524 100644
--- a/Jellyfin.Drawing.Skia/SkiaEncoder.cs
+++ b/Jellyfin.Drawing.Skia/SkiaEncoder.cs
@@ -227,8 +227,13 @@ 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 NullReferenceException(nameof(directory));
+ }
- Directory.CreateDirectory(Path.GetDirectoryName(tempPath));
+ Directory.CreateDirectory(directory);
File.Copy(path, tempPath, true);
return tempPath;
@@ -493,7 +498,13 @@ namespace Jellyfin.Drawing.Skia
// If all we're doing is resizing then we can stop now
if (!hasBackgroundColor && !hasForegroundColor && blur == 0 && !hasIndicator)
{
- Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
+ var outputDirectory = Path.GetDirectoryName(outputPath);
+ if (outputDirectory == null)
+ {
+ throw new NullReferenceException(nameof(outputDirectory));
+ }
+
+ Directory.CreateDirectory(outputDirectory);
using var outputStream = new SKFileWStream(outputPath);
using var pixmap = new SKPixmap(new SKImageInfo(width, height), resizedBitmap.GetPixels());
resizedBitmap.Encode(outputStream, skiaOutputFormat, quality);
@@ -540,7 +551,13 @@ namespace Jellyfin.Drawing.Skia
DrawIndicator(canvas, width, height, options);
}
- Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
+ var directory = Path.GetDirectoryName(outputPath);
+ if (directory == null)
+ {
+ throw new NullReferenceException(nameof(directory));
+ }
+
+ Directory.CreateDirectory(directory);
using (var outputStream = new SKFileWStream(outputPath))
{
using (var pixmap = new SKPixmap(new SKImageInfo(width, height), saveBitmap.GetPixels()))