diff options
| author | Nils Fürniß <contact@nalsai.de> | 2022-03-12 21:46:29 +0100 |
|---|---|---|
| committer | Nils Fürniß <contact@nalsai.de> | 2022-03-22 19:17:48 +0100 |
| commit | b4bb82b6d7537dde1ee868b1a1cf9d3652f83866 (patch) | |
| tree | bfed5f79f21a709f6a987c069c5870ff5c551d7d /MediaBrowser.MediaEncoding/Attachments | |
| parent | eb44f892b8f91451317fa63380f8c62907e24d1e (diff) | |
Improve code
Diffstat (limited to 'MediaBrowser.MediaEncoding/Attachments')
| -rw-r--r-- | MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs index eb58dd9e2..00aafa126 100644 --- a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs +++ b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs @@ -89,12 +89,12 @@ namespace MediaBrowser.MediaEncoding.Attachments string outputPath, CancellationToken cancellationToken) { - if (!Directory.Exists(outputPath)) - { - var semaphore = _semaphoreLocks.GetOrAdd(outputPath, key => new SemaphoreSlim(1, 1)); + var semaphore = _semaphoreLocks.GetOrAdd(outputPath, key => new SemaphoreSlim(1, 1)); - await semaphore.WaitAsync(cancellationToken).ConfigureAwait(false); + await semaphore.WaitAsync(cancellationToken).ConfigureAwait(false); + if (!Directory.Exists(outputPath)) + { try { await ExtractAllAttachmentsInternal( @@ -116,12 +116,12 @@ namespace MediaBrowser.MediaEncoding.Attachments string outputPath, CancellationToken cancellationToken) { - if (!File.Exists(Path.Join(outputPath, id))) - { - var semaphore = _semaphoreLocks.GetOrAdd(outputPath, key => new SemaphoreSlim(1, 1)); + var semaphore = _semaphoreLocks.GetOrAdd(outputPath, key => new SemaphoreSlim(1, 1)); - await semaphore.WaitAsync(cancellationToken).ConfigureAwait(false); + await semaphore.WaitAsync(cancellationToken).ConfigureAwait(false); + if (!File.Exists(Path.Join(outputPath, id))) + { try { await ExtractAllAttachmentsInternal( @@ -158,10 +158,7 @@ namespace MediaBrowser.MediaEncoding.Attachments throw new ArgumentNullException(nameof(outputPath)); } - if (!Directory.Exists(outputPath)) - { - Directory.CreateDirectory(outputPath); - } + Directory.CreateDirectory(outputPath); var processArgs = string.Format( CultureInfo.InvariantCulture, |
