aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgnattu <gnattu@users.noreply.github.com>2024-06-01 18:41:00 -0400
committerJoshua M. Boniface <joshua@boniface.me>2024-06-01 18:41:00 -0400
commitc4b7c91f3a4f4219f88166f87d84f045231a6271 (patch)
tree1f9745569e42da3629e787165b8649897905a1b9
parent1a9497675272ad538c99892fa160d83b10a26f5e (diff)
Backport pull request #11812 from jellyfin/release-10.9.z
Extract media attachment one by one if the filename appears to be a path Original-merge: 45e8872cc086fe2b086e209a08839b3ff689ecf3 Merged-by: crobibero <cody@robibe.ro> Backported-by: Joshua M. Boniface <joshua@boniface.me>
-rw-r--r--MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs27
1 files changed, 20 insertions, 7 deletions
diff --git a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
index 3b7745b6a..914990558 100644
--- a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
+++ b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
@@ -89,15 +89,28 @@ namespace MediaBrowser.MediaEncoding.Attachments
string outputPath,
CancellationToken cancellationToken)
{
- using (await _semaphoreLocks.LockAsync(outputPath, cancellationToken).ConfigureAwait(false))
+ var shouldExtractOneByOne = mediaSource.MediaAttachments.Any(a => a.FileName.Contains('/', StringComparison.OrdinalIgnoreCase) || a.FileName.Contains('\\', StringComparison.OrdinalIgnoreCase));
+ if (shouldExtractOneByOne)
{
- if (!Directory.Exists(outputPath))
+ var attachmentIndexes = mediaSource.MediaAttachments.Select(a => a.Index);
+ foreach (var i in attachmentIndexes)
{
- await ExtractAllAttachmentsInternal(
- _mediaEncoder.GetInputArgument(inputFile, mediaSource),
- outputPath,
- false,
- cancellationToken).ConfigureAwait(false);
+ var newName = Path.Join(outputPath, i.ToString(CultureInfo.InvariantCulture));
+ await ExtractAttachment(inputFile, mediaSource, i, newName, cancellationToken).ConfigureAwait(false);
+ }
+ }
+ else
+ {
+ using (await _semaphoreLocks.LockAsync(outputPath, cancellationToken).ConfigureAwait(false))
+ {
+ if (!Directory.Exists(outputPath))
+ {
+ await ExtractAllAttachmentsInternal(
+ _mediaEncoder.GetInputArgument(inputFile, mediaSource),
+ outputPath,
+ false,
+ cancellationToken).ConfigureAwait(false);
+ }
}
}
}