77using System . Runtime . InteropServices ;
88using System . Threading . Tasks ;
99using Microsoft . AspNetCore . Hosting ;
10- using Microsoft . Extensions . FileProviders ;
1110using Microsoft . Extensions . Options ;
1211using SixLabors . ImageSharp . Web . Resolvers ;
1312
@@ -28,11 +27,6 @@ public class PhysicalFileSystemCache : IImageCache
2827 /// </summary>
2928 private readonly int cacheFolderDepth ;
3029
31- /// <summary>
32- /// The file provider abstraction.
33- /// </summary>
34- private readonly IFileProvider fileProvider ;
35-
3630 /// <summary>
3731 /// Contains various format helper methods based on the current configuration.
3832 /// </summary>
@@ -54,18 +48,13 @@ public PhysicalFileSystemCache(
5448 FormatUtilities formatUtilities )
5549 {
5650 Guard . NotNull ( environment , nameof ( environment ) ) ;
57- Guard . NotNull ( options , nameof ( options ) ) ;
5851 Guard . NotNullOrWhiteSpace ( environment . WebRootPath , nameof ( environment . WebRootPath ) ) ;
5952
6053 // Allow configuration of the cache without having to register everything
6154 PhysicalFileSystemCacheOptions cacheOptions = options != null ? options . Value : new ( ) ;
6255 this . cacheRootPath = GetCacheRoot ( cacheOptions , environment . WebRootPath , environment . ContentRootPath ) ;
6356 this . cacheFolderDepth = ( int ) cacheOptions . CacheFolderDepth ;
6457
65- // Ensure cache directory is created before initializing the file provider
66- Directory . CreateDirectory ( this . cacheRootPath ) ;
67-
68- this . fileProvider = new PhysicalFileProvider ( this . cacheRootPath ) ;
6958 this . formatUtilities = formatUtilities ;
7059 }
7160
@@ -92,7 +81,7 @@ public Task<IImageCacheResolver> GetAsync(string key)
9281 {
9382 string path = ToFilePath ( key , this . cacheFolderDepth ) ;
9483
95- IFileInfo metaFileInfo = this . fileProvider . GetFileInfo ( this . ToMetaDataFilePath ( path ) ) ;
84+ var metaFileInfo = new FileInfo ( this . ToMetaDataFilePath ( path ) ) ;
9685 if ( ! metaFileInfo . Exists )
9786 {
9887 return Task . FromResult < IImageCacheResolver > ( null ) ;
0 commit comments