Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Useless variable closure #14869

Merged
merged 5 commits into from
Dec 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Piedone marked this conversation as resolved.
Show resolved Hide resolved
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