mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-04 06:04:25 -04:00
Dispose of process correctly in AttachmentExtractor
This commit is contained in:
parent
1c13be085f
commit
d705931e81
@ -164,35 +164,33 @@ namespace MediaBrowser.MediaEncoding.Attachments
|
|||||||
WindowStyle = ProcessWindowStyle.Hidden,
|
WindowStyle = ProcessWindowStyle.Hidden,
|
||||||
ErrorDialog = false
|
ErrorDialog = false
|
||||||
};
|
};
|
||||||
var process = new Process
|
|
||||||
|
int exitCode;
|
||||||
|
|
||||||
|
using (var process = new Process { StartInfo = startInfo, EnableRaisingEvents = true })
|
||||||
{
|
{
|
||||||
StartInfo = startInfo,
|
_logger.LogInformation("{File} {Arguments}", process.StartInfo.FileName, process.StartInfo.Arguments);
|
||||||
EnableRaisingEvents = true
|
|
||||||
};
|
|
||||||
|
|
||||||
_logger.LogInformation("{File} {Arguments}", process.StartInfo.FileName, process.StartInfo.Arguments);
|
process.Start();
|
||||||
|
|
||||||
process.Start();
|
var ranToCompletion = await process.WaitForExitAsync(cancellationToken);
|
||||||
|
|
||||||
var ranToCompletion = await process.WaitForExitAsync(cancellationToken);
|
if (!ranToCompletion)
|
||||||
|
|
||||||
if (!ranToCompletion)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Killing ffmpeg attachment extraction process");
|
try
|
||||||
process.Kill();
|
{
|
||||||
}
|
_logger.LogWarning("Killing ffmpeg attachment extraction process");
|
||||||
catch (Exception ex)
|
process.Kill();
|
||||||
{
|
}
|
||||||
_logger.LogError(ex, "Error killing attachment extraction process");
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error killing attachment extraction process");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exitCode = ranToCompletion ? process.ExitCode : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var exitCode = ranToCompletion ? process.ExitCode : -1;
|
|
||||||
|
|
||||||
process.Dispose();
|
|
||||||
|
|
||||||
var failed = false;
|
var failed = false;
|
||||||
|
|
||||||
if (exitCode != 0)
|
if (exitCode != 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user