diff options
| author | Mark Cilia Vincenti <markciliavincenti@gmail.com> | 2024-05-06 03:21:54 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-05 19:21:54 -0600 |
| commit | af74aa35d76435f5bd01aeec77f406376b3b8c28 (patch) | |
| tree | 41a541eceb1a7a970c3873ec472c80c0a7300026 /MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs | |
| parent | 688a734895379c1bb452a4c5a292fbda85e7cc2e (diff) | |
Clean up synchronization (#11458)
Diffstat (limited to 'MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs')
| -rw-r--r-- | MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs index a11440ced..3b7745b6a 100644 --- a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs +++ b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs @@ -247,7 +247,7 @@ namespace MediaBrowser.MediaEncoding.Attachments MediaSourceInfo mediaSource, CancellationToken cancellationToken) { - var outputFileLocks = new List<AsyncKeyedLockReleaser<string>>(); + var outputFileLocks = new List<IDisposable>(); var extractableAttachmentIds = new List<int>(); try @@ -256,16 +256,15 @@ namespace MediaBrowser.MediaEncoding.Attachments { var outputPath = GetAttachmentCachePath(mediaPath, mediaSource, attachment.Index); - var @outputFileLock = _semaphoreLocks.GetOrAdd(outputPath); - await @outputFileLock.SemaphoreSlim.WaitAsync(cancellationToken).ConfigureAwait(false); + var releaser = await _semaphoreLocks.LockAsync(outputPath, cancellationToken).ConfigureAwait(false); if (File.Exists(outputPath)) { - @outputFileLock.Dispose(); + releaser.Dispose(); continue; } - outputFileLocks.Add(@outputFileLock); + outputFileLocks.Add(releaser); extractableAttachmentIds.Add(attachment.Index); } @@ -280,10 +279,7 @@ namespace MediaBrowser.MediaEncoding.Attachments } finally { - foreach (var @outputFileLock in outputFileLocks) - { - @outputFileLock.Dispose(); - } + outputFileLocks.ForEach(x => x.Dispose()); } } |
