Skip to content

Commit

Permalink
Useless variable closure (OrchardCMS#14869)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtkech authored and urbanit committed Mar 18, 2024
1 parent 19dcd14 commit 6bdfaae
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public async Task Invoke(HttpContext context)
return;
}

// subpath.Value returns an unescaped path value, subPath returns an escaped path value.
// subPath.Value returns an unescaped path value, subPath returns an escaped path value.
var subPathValue = subPath.Value;

var isFileCached = await _mediaFileStoreCache.IsCachedAsync(subPathValue);
Expand All @@ -79,11 +79,11 @@ public async Task Invoke(HttpContext context)

// When multiple requests occur for the same file we use a Lazy<Task>
// to initialize the file store request once.
await _workers.GetOrAdd(subPathValue, x => new Lazy<Task>(async () =>
await _workers.GetOrAdd(subPathValue, path => new Lazy<Task>(async () =>
{
try
{
var fileStoreEntry = await _mediaFileStore.GetFileInfoAsync(subPathValue);
var fileStoreEntry = await _mediaFileStore.GetFileInfoAsync(path);
if (fileStoreEntry != null)
{
Expand All @@ -94,13 +94,13 @@ public async Task Invoke(HttpContext context)
catch (Exception ex)
{
// Log the error, and pass to pipeline to handle as 404.
// Multiple requests at the same time will all recieve the same 404
// Multiple requests at the same time will all receive the same 404
// as we use LazyThreadSafetyMode.ExecutionAndPublication.
_logger.LogError(ex, "Error retrieving file from media file store for request path {Path}", subPathValue);
_logger.LogError(ex, "Error retrieving file from media file store for request path {Path}", path);
}
finally
{
_workers.TryRemove(subPathValue, out var writeTask);
_workers.TryRemove(path, out var writeTask);
}
}, LazyThreadSafetyMode.ExecutionAndPublication)).Value;

Expand Down

0 comments on commit 6bdfaae

Please sign in to comment.