Skip to content

Commit 295208d

Browse files
Fix metadata check
1 parent b91e3b6 commit 295208d

2 files changed

Lines changed: 9 additions & 13 deletions

File tree

src/ImageSharp.Web/ImageCacheMetadata.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,11 @@ public static async Task<ImageCacheMetadata> ReadAsync(Stream stream)
156156
/// <inheritdoc/>
157157
[MethodImpl(MethodImplOptions.AggressiveInlining)]
158158
public bool Equals(ImageCacheMetadata other)
159-
{
160-
return this.SourceLastWriteTimeUtc == other.SourceLastWriteTimeUtc
161-
&& this.CacheLastWriteTimeUtc == other.CacheLastWriteTimeUtc
162-
&& this.ContentType == other.ContentType
163-
&& this.CacheControlMaxAge == other.CacheControlMaxAge
164-
&& this.ContentLength == other.ContentLength;
165-
}
159+
=> this.SourceLastWriteTimeUtc == other.SourceLastWriteTimeUtc
160+
&& this.CacheLastWriteTimeUtc == other.CacheLastWriteTimeUtc
161+
&& this.ContentType == other.ContentType
162+
&& this.CacheControlMaxAge == other.CacheControlMaxAge
163+
&& this.ContentLength == other.ContentLength;
166164

167165
/// <inheritdoc/>
168166
public override bool Equals(object obj)
@@ -181,16 +179,14 @@ public override int GetHashCode() => HashCode.Combine(
181179
/// </summary>
182180
/// <returns>The <see cref="Dictionary{String, String}"/>.</returns>
183181
public Dictionary<string, string> ToDictionary()
184-
{
185-
return new Dictionary<string, string>
182+
=> new()
186183
{
187184
{ SourceLastModifiedKey, this.SourceLastWriteTimeUtc.ToString("o") },
188185
{ CacheLastModifiedKey, this.CacheLastWriteTimeUtc.ToString("o") },
189186
{ ContentTypeKey, this.ContentType },
190187
{ CacheControlKey, this.CacheControlMaxAge.TotalSeconds.ToString(NumberFormatInfo.InvariantInfo) },
191188
{ ContentLengthKey, this.ContentLength.ToString(NumberFormatInfo.InvariantInfo) }
192189
};
193-
}
194190

195191
/// <inheritdoc/>
196192
public override string ToString()

src/ImageSharp.Web/Resolvers/PhysicalFileSystemCacheResolver.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public PhysicalFileSystemCacheResolver(FileInfo metaFileInfo, FormatUtilities fo
3333
/// <inheritdoc/>
3434
public async Task<ImageCacheMetadata> GetMetaDataAsync()
3535
{
36-
using Stream stream = OpenFileStream(this.metaFileInfo.FullName);
3736
if (this.metadata == default)
3837
{
38+
using Stream stream = OpenFileStream(this.metaFileInfo.FullName);
3939
this.metadata = await ImageCacheMetadata.ReadAsync(stream);
4040
}
4141

@@ -49,11 +49,11 @@ public Task<Stream> OpenReadAsync()
4949
this.metaFileInfo.FullName,
5050
this.formatUtilities.GetExtensionFromContentType(this.metadata.ContentType));
5151

52-
return Task.FromResult(OpenFileStream(path));
52+
return Task.FromResult<Stream>(OpenFileStream(path));
5353
}
5454

5555
[MethodImpl(MethodImplOptions.AggressiveInlining)]
56-
private static Stream OpenFileStream(string path)
56+
private static FileStream OpenFileStream(string path)
5757
{
5858
// We are setting buffer size to 1 to prevent FileStream from allocating it's internal buffer
5959
// 0 causes constructor to throw

0 commit comments

Comments
 (0)