mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Remove temp file even when saving failed
This commit is contained in:
parent
3aefbf8cf6
commit
e9ee0ef1f5
@ -258,15 +258,37 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
throw new ArgumentNullException(nameof(source));
|
throw new ArgumentNullException(nameof(source));
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileStream = AsyncFile.OpenRead(source);
|
Exception? saveException = null;
|
||||||
await new ImageSaver(_configurationManager, _libraryMonitor, _fileSystem, _logger).SaveImage(item, fileStream, mimeType, type, imageIndex, saveLocallyWithMedia, cancellationToken);
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.Delete(source);
|
var fileStream = AsyncFile.OpenRead(source);
|
||||||
|
await new ImageSaver(_configurationManager, _libraryMonitor, _fileSystem, _logger).SaveImage(item, fileStream, mimeType, type, imageIndex, saveLocallyWithMedia, cancellationToken);
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Source file {Source} not found or in use, skip removing", source);
|
saveException = ex;
|
||||||
|
_logger.LogError(ex, "Unable to save image {Source}", source);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Delete(source);
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Source file {Source} not found or in use, skip removing", source);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
saveException ??= ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (saveException is not null)
|
||||||
|
{
|
||||||
|
throw saveException;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user