Fix releasing lock

This commit is contained in:
Nils Fürniß 2022-03-13 11:20:09 +01:00
parent b4bb82b6d7
commit d7d36a102a
No known key found for this signature in database
GPG Key ID: 79CB1318699409FF

View File

@ -93,9 +93,9 @@ namespace MediaBrowser.MediaEncoding.Attachments
await semaphore.WaitAsync(cancellationToken).ConfigureAwait(false); await semaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
if (!Directory.Exists(outputPath))
{
try try
{
if (!Directory.Exists(outputPath))
{ {
await ExtractAllAttachmentsInternal( await ExtractAllAttachmentsInternal(
_mediaEncoder.GetInputArgument(inputFile, mediaSource), _mediaEncoder.GetInputArgument(inputFile, mediaSource),
@ -103,12 +103,12 @@ namespace MediaBrowser.MediaEncoding.Attachments
false, false,
cancellationToken).ConfigureAwait(false); cancellationToken).ConfigureAwait(false);
} }
}
finally finally
{ {
semaphore.Release(); semaphore.Release();
} }
} }
}
public async Task ExtractAllAttachmentsExternal( public async Task ExtractAllAttachmentsExternal(
string inputArgument, string inputArgument,
@ -120,26 +120,26 @@ namespace MediaBrowser.MediaEncoding.Attachments
await semaphore.WaitAsync(cancellationToken).ConfigureAwait(false); await semaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
if (!File.Exists(Path.Join(outputPath, id)))
{
try try
{
if (!File.Exists(Path.Join(outputPath, id)))
{ {
await ExtractAllAttachmentsInternal( await ExtractAllAttachmentsInternal(
inputArgument, inputArgument,
outputPath, outputPath,
true, true,
cancellationToken).ConfigureAwait(false); cancellationToken).ConfigureAwait(false);
}
finally
{
if (Directory.Exists(outputPath)) if (Directory.Exists(outputPath))
{ {
File.Create(Path.Join(outputPath, id)); File.Create(Path.Join(outputPath, id));
} }
semaphore.Release();
} }
} }
finally
{
semaphore.Release();
}
} }
private async Task ExtractAllAttachmentsInternal( private async Task ExtractAllAttachmentsInternal(