mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Improve code
This commit is contained in:
parent
eb44f892b8
commit
b4bb82b6d7
@ -88,13 +88,13 @@ namespace MediaBrowser.MediaEncoding.Attachments
|
|||||||
MediaSourceInfo mediaSource,
|
MediaSourceInfo mediaSource,
|
||||||
string outputPath,
|
string outputPath,
|
||||||
CancellationToken cancellationToken)
|
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
|
try
|
||||||
{
|
{
|
||||||
await ExtractAllAttachmentsInternal(
|
await ExtractAllAttachmentsInternal(
|
||||||
@ -115,13 +115,13 @@ namespace MediaBrowser.MediaEncoding.Attachments
|
|||||||
string id,
|
string id,
|
||||||
string outputPath,
|
string outputPath,
|
||||||
CancellationToken cancellationToken)
|
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
|
try
|
||||||
{
|
{
|
||||||
await ExtractAllAttachmentsInternal(
|
await ExtractAllAttachmentsInternal(
|
||||||
@ -158,10 +158,7 @@ namespace MediaBrowser.MediaEncoding.Attachments
|
|||||||
throw new ArgumentNullException(nameof(outputPath));
|
throw new ArgumentNullException(nameof(outputPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Directory.Exists(outputPath))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(outputPath);
|
Directory.CreateDirectory(outputPath);
|
||||||
}
|
|
||||||
|
|
||||||
var processArgs = string.Format(
|
var processArgs = string.Format(
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user