aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
diff options
context:
space:
mode:
authorgnattu <gnattu@users.noreply.github.com>2024-11-19 15:43:31 -0500
committerJoshua M. Boniface <joshua@boniface.me>2024-11-19 15:43:31 -0500
commit7f81bbd42f0b2dbab4887f515ec6fb3c89c47745 (patch)
treeca794e59e21f664d38317828aa63ae8e035fb1c3 /MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
parent9f86f8748cc173a065b21c35641407a8cfa08bf7 (diff)
Backport pull request #13030 from jellyfin/release-10.10.z
Always cleanup trickplay temp for ffmpeg failures Original-merge: 9e61a6fd729b2980832014ae42bd4f7d1f3afb69 Merged-by: crobibero <cody@robibe.ro> Backported-by: Joshua M. Boniface <joshua@boniface.me>
Diffstat (limited to 'MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs')
-rw-r--r--MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs10
1 files changed, 10 insertions, 0 deletions
diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
index 826ffd0b7..a34238cd6 100644
--- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
+++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
@@ -1035,6 +1035,16 @@ namespace MediaBrowser.MediaEncoding.Encoder
if (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));
}