The Free Software Media System - Server Backend & API
Backport pull request #13030 from jellyfin/release-10.10.z
gnattu7f81bbd42f0b
diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.csindex 826ffd0b7e..a34238cd68 100644--- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs+++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs@@ -1035,6 +1035,16 @@ namespace MediaBrowser.MediaEncoding.Encoderif (exitCode == -1){_logger.LogError("ffmpeg image extraction failed for {ProcessDescription}", processDescription);+ // Cleanup temp folder here, because the targetDirectory is not returned and the cleanup for failed ffmpeg process is not possible for caller.+ // Ideally the ffmpeg should not write any files if it fails, but it seems like it is not guaranteed.+ try+ {+ Directory.Delete(targetDirectory, true);+ }+ catch (Exception e)+ {+ _logger.LogError(e, "Failed to delete ffmpeg temp directory {TargetDirectory}", targetDirectory);+ }throw new FfmpegException(string.Format(CultureInfo.InvariantCulture, "ffmpeg image extraction failed for {0}", processDescription));}