From b9361fb84df92f1cdf4ff52124e14f4ac6a6b80f Mon Sep 17 00:00:00 2001 From: jtkech Date: Sat, 9 Dec 2023 04:00:51 +0100 Subject: [PATCH 1/4] Fix Media Worker --- .../Services/MediaFileStoreResolverMiddleware.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Media/Services/MediaFileStoreResolverMiddleware.cs b/src/OrchardCore.Modules/OrchardCore.Media/Services/MediaFileStoreResolverMiddleware.cs index 7ee626f0d7f..5c6b79e812f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Media/Services/MediaFileStoreResolverMiddleware.cs +++ b/src/OrchardCore.Modules/OrchardCore.Media/Services/MediaFileStoreResolverMiddleware.cs @@ -79,7 +79,7 @@ public async Task Invoke(HttpContext context) // When multiple requests occur for the same file we use a Lazy // to initialize the file store request once. - await _workers.GetOrAdd(subPathValue, x => new Lazy(async () => + await _workers.GetOrAdd(subPathValue, subPathValue => new Lazy(async () => { try { @@ -94,7 +94,7 @@ 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); } From 8966f84e16ee416cea717e79f83c1d2f31909ae5 Mon Sep 17 00:00:00 2001 From: jtkech Date: Sat, 9 Dec 2023 04:15:27 +0100 Subject: [PATCH 2/4] another typo --- .../Services/MediaFileStoreResolverMiddleware.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Media/Services/MediaFileStoreResolverMiddleware.cs b/src/OrchardCore.Modules/OrchardCore.Media/Services/MediaFileStoreResolverMiddleware.cs index 5c6b79e812f..de42aa77bd9 100644 --- a/src/OrchardCore.Modules/OrchardCore.Media/Services/MediaFileStoreResolverMiddleware.cs +++ b/src/OrchardCore.Modules/OrchardCore.Media/Services/MediaFileStoreResolverMiddleware.cs @@ -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); From 540db7caeca99697ac8dfce74ce54e84d87a4b29 Mon Sep 17 00:00:00 2001 From: jtkech Date: Tue, 19 Dec 2023 21:08:34 +0100 Subject: [PATCH 3/4] Separate name for lambda variable --- .../Services/MediaFileStoreResolverMiddleware.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Media/Services/MediaFileStoreResolverMiddleware.cs b/src/OrchardCore.Modules/OrchardCore.Media/Services/MediaFileStoreResolverMiddleware.cs index de42aa77bd9..21f560c4e83 100644 --- a/src/OrchardCore.Modules/OrchardCore.Media/Services/MediaFileStoreResolverMiddleware.cs +++ b/src/OrchardCore.Modules/OrchardCore.Media/Services/MediaFileStoreResolverMiddleware.cs @@ -79,11 +79,11 @@ public async Task Invoke(HttpContext context) // When multiple requests occur for the same file we use a Lazy // to initialize the file store request once. - await _workers.GetOrAdd(subPathValue, subPathValue => new Lazy(async () => + await _workers.GetOrAdd(subPathValue, path => new Lazy(async () => { try { - var fileStoreEntry = await _mediaFileStore.GetFileInfoAsync(subPathValue); + var fileStoreEntry = await _mediaFileStore.GetFileInfoAsync(path); if (fileStoreEntry != null) { @@ -96,7 +96,7 @@ public async Task Invoke(HttpContext context) // Log the error, and pass to pipeline to handle as 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 { From e9da33aef57b2e65af9d6e036bb5f6da61f1b1a6 Mon Sep 17 00:00:00 2001 From: jtkech Date: Wed, 20 Dec 2023 08:38:33 +0100 Subject: [PATCH 4/4] Missing change --- .../Services/MediaFileStoreResolverMiddleware.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Media/Services/MediaFileStoreResolverMiddleware.cs b/src/OrchardCore.Modules/OrchardCore.Media/Services/MediaFileStoreResolverMiddleware.cs index 21f560c4e83..2df251d0655 100644 --- a/src/OrchardCore.Modules/OrchardCore.Media/Services/MediaFileStoreResolverMiddleware.cs +++ b/src/OrchardCore.Modules/OrchardCore.Media/Services/MediaFileStoreResolverMiddleware.cs @@ -100,7 +100,7 @@ public async Task Invoke(HttpContext context) } finally { - _workers.TryRemove(subPathValue, out var writeTask); + _workers.TryRemove(path, out var writeTask); } }, LazyThreadSafetyMode.ExecutionAndPublication)).Value;