66namespace Our . Umbraco . FileSystemProviders . Azure
77{
88 using System ;
9- using System . Diagnostics . CodeAnalysis ;
109 using System . Reflection ;
1110 using System . Web ;
1211 using System . Web . Compilation ;
1312 using System . Web . Hosting ;
14- using global ::Umbraco . Core . Composing ;
1513 using global ::Umbraco . Core . IO ;
1614
1715 /// <summary>
@@ -69,17 +67,19 @@ public FileSystemVirtualPathProvider(string pathPrefix, Lazy<IFileSystem> fileSy
6967 /// <param name="pathPrefix">
7068 /// The path prefix.
7169 /// </param>
70+ /// <param name="fileSystem">
71+ /// The file system.
72+ /// </param>
7273 /// <exception cref="ArgumentNullException">
7374 /// Thrown if <paramref name="pathPrefix"/> is null.
7475 /// </exception>
75- public static void Configure ( string pathPrefix = Constants . DefaultMediaRoute )
76+ public static void Configure ( string pathPrefix , Lazy < IFileSystem > fileSystem )
7677 {
7778 if ( string . IsNullOrEmpty ( pathPrefix ) )
7879 {
7980 throw new ArgumentNullException ( nameof ( pathPrefix ) ) ;
8081 }
8182
82- Lazy < IFileSystem > fileSystem = new Lazy < IFileSystem > ( ( ) => Current . MediaFileSystem . Unwrap ( ) ) ;
8383 FileSystemVirtualPathProvider provider = new FileSystemVirtualPathProvider ( pathPrefix , fileSystem ) ;
8484
8585 // The standard HostingEnvironment.RegisterVirtualPathProvider(virtualPathProvider) method is ignored when
@@ -113,18 +113,6 @@ public static void Configure(string pathPrefix = Constants.DefaultMediaRoute)
113113 }
114114 }
115115
116- /// <summary>
117- /// Configures the virtual path provider for media.
118- /// </summary>
119- /// <param name="pathPrefix">
120- /// The path prefix.
121- /// </param>
122- [ SuppressMessage ( "StyleCop.CSharp.ReadabilityRules" , "SA1126:PrefixCallsCorrectly" , Justification = "Resharper seems drunk." ) ]
123- public static void ConfigureMedia ( string pathPrefix = Constants . DefaultMediaRoute )
124- {
125- Configure ( pathPrefix ) ;
126- }
127-
128116 /// <summary>
129117 /// Gets a value that indicates whether a file exists in the virtual file system.
130118 /// </summary>
@@ -142,6 +130,7 @@ public override bool FileExists(string virtualPath)
142130 }
143131
144132 string fileSystemPath = this . RemovePathPrefix ( path ) ;
133+
145134 return this . fileSystem . Value . FileExists ( fileSystemPath ) ;
146135 }
147136
@@ -156,6 +145,7 @@ public override bool FileExists(string virtualPath)
156145 public override VirtualFile GetFile ( string virtualPath )
157146 {
158147 string path = this . FormatVirtualPath ( virtualPath ) ;
148+
159149 if ( ! path . StartsWith ( this . pathPrefix , StringComparison . InvariantCultureIgnoreCase ) )
160150 {
161151 return base . GetFile ( virtualPath ) ;
0 commit comments