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,
|
||||
ErrorDialog = false
|
||||
};
|
||||
var process = new Process
|
||||
|
||||
int exitCode;
|
||||
|
||||
using (var process = new Process { StartInfo = startInfo, EnableRaisingEvents = true })
|
||||
{
|
||||
StartInfo = startInfo,
|
||||
EnableRaisingEvents = true
|
||||
};
|
||||
_logger.LogInformation("{File} {Arguments}", process.StartInfo.FileName, process.StartInfo.Arguments);
|
||||
|
||||
_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)
|
||||
{
|
||||
try
|
||||
if (!ranToCompletion)
|
||||
{
|
||||
_logger.LogWarning("Killing ffmpeg attachment extraction process");
|
||||
process.Kill();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error killing attachment extraction process");
|
||||
try
|
||||
{
|
||||
_logger.LogWarning("Killing ffmpeg attachment extraction process");
|
||||
process.Kill();
|
||||
}
|
||||
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;
|
||||
|
||||
if (exitCode != 0)
|
||||
|
|
Loading…
Reference in New Issue
Block a user