mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-01-15 15:48:03 +00:00
Backport pull request #15659 from jellyfin/release-10.11.z
Fix thumbnails never deletes from temp folder ( issue #15629 )
Original-merge: 636908fc4d
Merged-by: crobibero <cody@robibe.ro>
Backported-by: Bond_009 <bond.009@outlook.com>
This commit is contained in:
@@ -209,8 +209,11 @@ public class SkiaEncoder : IImageEncoder
|
|||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
using var codec = SKCodec.Create(safePath, out var result);
|
SKCodec? codec = null;
|
||||||
|
bool isSafePathTemp = !string.Equals(Path.GetFullPath(safePath), Path.GetFullPath(path), StringComparison.OrdinalIgnoreCase);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
codec = SKCodec.Create(safePath, out var result);
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
case SKCodecResult.Success:
|
case SKCodecResult.Success:
|
||||||
@@ -231,7 +234,6 @@ public class SkiaEncoder : IImageEncoder
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
var boundsInfo = SKBitmap.DecodeBounds(safePath);
|
var boundsInfo = SKBitmap.DecodeBounds(safePath);
|
||||||
|
|
||||||
if (boundsInfo.Width > 0 && boundsInfo.Height > 0)
|
if (boundsInfo.Width > 0 && boundsInfo.Height > 0)
|
||||||
{
|
{
|
||||||
return new ImageDimensions(boundsInfo.Width, boundsInfo.Height);
|
return new ImageDimensions(boundsInfo.Width, boundsInfo.Height);
|
||||||
@@ -241,10 +243,38 @@ public class SkiaEncoder : IImageEncoder
|
|||||||
"Unable to determine image dimensions for {FilePath}: {SkCodecResult}",
|
"Unable to determine image dimensions for {FilePath}: {SkCodecResult}",
|
||||||
path,
|
path,
|
||||||
result);
|
result);
|
||||||
|
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
codec?.Dispose();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogDebug(ex, "Error by closing codec for {FilePath}", safePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSafePathTemp)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (File.Exists(safePath))
|
||||||
|
{
|
||||||
|
File.Delete(safePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogDebug(ex, "Unable to remove temporary file '{TempPath}'", safePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
/// <exception cref="ArgumentNullException">The path is null.</exception>
|
/// <exception cref="ArgumentNullException">The path is null.</exception>
|
||||||
|
|||||||
Reference in New Issue
Block a user