Skip to content

Commit 2acb001

Browse files
committed
Reverted nullable changes on S3 provider and resolver files
1 parent 2f9904d commit 2acb001

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

src/ImageSharp.Web.Providers.AWS/Providers/AWSS3StorageImageProvider.cs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
3+
#nullable disable
34

45
using Amazon.S3;
56
using Amazon.S3.Model;
@@ -28,7 +29,7 @@ private readonly Dictionary<string, AmazonS3Client> buckets
2829
= new();
2930

3031
private readonly AWSS3StorageImageProviderOptions storageOptions;
31-
private Func<HttpContext, bool>? match;
32+
private Func<HttpContext, bool> match;
3233

3334
/// <summary>
3435
/// Contains various helper methods based on the current configuration.
@@ -69,23 +70,17 @@ public bool IsValidRequest(HttpContext context)
6970
=> this.formatUtilities.TryGetExtensionFromUri(context.Request.GetDisplayUrl(), out _);
7071

7172
/// <inheritdoc />
72-
public async Task<IImageResolver?> GetAsync(HttpContext context)
73+
public async Task<IImageResolver> GetAsync(HttpContext context)
7374
{
7475
// Strip the leading slash and bucket name from the HTTP request path and treat
7576
// the remaining path string as the key.
7677
// Path has already been correctly parsed before here.
7778
string bucketName = string.Empty;
78-
IAmazonS3? s3Client = null;
79+
IAmazonS3 s3Client = null;
7980

8081
// We want an exact match here to ensure that bucket names starting with
8182
// the same prefix are not mixed up.
82-
string? path = context.Request.Path.Value?.TrimStart(SlashChars);
83-
84-
if (path is null)
85-
{
86-
return null;
87-
}
88-
83+
string path = context.Request.Path.Value.TrimStart(SlashChars);
8984
int index = path.IndexOfAny(SlashChars);
9085
string nameToMatch = index != -1 ? path.Substring(0, index) : path;
9186

@@ -126,13 +121,7 @@ private bool IsMatch(HttpContext context)
126121
{
127122
// Only match loosly here for performance.
128123
// Path matching conflicts should be dealt with by configuration.
129-
string? path = context.Request.Path.Value?.TrimStart(SlashChars);
130-
131-
if (path is null)
132-
{
133-
return false;
134-
}
135-
124+
string path = context.Request.Path.Value.TrimStart(SlashChars);
136125
foreach (string bucket in this.buckets.Keys)
137126
{
138127
if (path.StartsWith(bucket, StringComparison.OrdinalIgnoreCase))
@@ -177,7 +166,7 @@ private static async Task<KeyExistsResult> KeyExists(IAmazonS3 s3Client, string
177166
}
178167
}
179168

180-
private readonly record struct KeyExistsResult(GetObjectMetadataResponse? Metadata)
169+
private readonly record struct KeyExistsResult(GetObjectMetadataResponse Metadata)
181170
{
182171
public bool Exists => this.Metadata is not null;
183172
}

src/ImageSharp.Web.Providers.AWS/Resolvers/AWSS3StorageImageResolver.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
3+
#nullable disable
34

45
using System.Net.Http.Headers;
56
using Amazon.S3;
@@ -15,7 +16,7 @@ public class AWSS3StorageImageResolver : IImageResolver
1516
private readonly IAmazonS3 amazonS3;
1617
private readonly string bucketName;
1718
private readonly string imagePath;
18-
private readonly GetObjectMetadataResponse? metadataResponse;
19+
private readonly GetObjectMetadataResponse metadataResponse;
1920

2021
/// <summary>
2122
/// Initializes a new instance of the <see cref="AWSS3StorageImageResolver"/> class.
@@ -24,7 +25,7 @@ public class AWSS3StorageImageResolver : IImageResolver
2425
/// <param name="bucketName">The bucket name.</param>
2526
/// <param name="imagePath">The image path.</param>
2627
/// <param name="metadataResponse">Optional metadata response.</param>
27-
public AWSS3StorageImageResolver(IAmazonS3 amazonS3, string bucketName, string imagePath, GetObjectMetadataResponse? metadataResponse = null)
28+
public AWSS3StorageImageResolver(IAmazonS3 amazonS3, string bucketName, string imagePath, GetObjectMetadataResponse metadataResponse = null)
2829
{
2930
this.amazonS3 = amazonS3;
3031
this.bucketName = bucketName;
@@ -40,7 +41,7 @@ public async Task<ImageMetadata> GetMetaDataAsync()
4041
// Try to parse the max age from the source. If it's not zero then we pass it along
4142
// to set the cache control headers for the response.
4243
TimeSpan maxAge = TimeSpan.MinValue;
43-
if (CacheControlHeaderValue.TryParse(metadata.Headers.CacheControl, out CacheControlHeaderValue? cacheControl))
44+
if (CacheControlHeaderValue.TryParse(metadata.Headers.CacheControl, out CacheControlHeaderValue cacheControl))
4445
{
4546
// Weirdly passing null to TryParse returns true.
4647
if (cacheControl?.MaxAge.HasValue == true)

0 commit comments

Comments
 (0)