2
2
// Copyright (c) James Jackson-South, Jeavon Leopold, and contributors. All rights reserved.
3
3
// Licensed under the Apache License, Version 2.0.
4
4
// </copyright>
5
-
6
5
namespace Our . Umbraco . FileSystemProviders . Azure
7
6
{
8
7
using System ;
@@ -43,7 +42,7 @@ internal class AzureFileSystem : IFileSystem
43
42
/// <summary>
44
43
/// A list of <see cref="AzureFileSystem"/>.
45
44
/// </summary>
46
- private static List < AzureFileSystem > fileSystems = new List < AzureFileSystem > ( ) ;
45
+ private static readonly List < AzureFileSystem > FileSystems = new List < AzureFileSystem > ( ) ;
47
46
48
47
/// <summary>
49
48
/// The root url.
@@ -153,7 +152,7 @@ public AzureFileSystem GetInstance(string containerName, string rootUrl, string
153
152
{
154
153
lock ( Locker )
155
154
{
156
- if ( fileSystems . SingleOrDefault ( fs => fs . ContainerName == containerName && fs . rootBlobUrl == rootUrl ) == null )
155
+ if ( FileSystems . SingleOrDefault ( fs => fs . ContainerName == containerName && fs . rootBlobUrl == rootUrl ) == null )
157
156
{
158
157
int max ;
159
158
if ( ! int . TryParse ( maxDays , out max ) )
@@ -167,19 +166,11 @@ public AzureFileSystem GetInstance(string containerName, string rootUrl, string
167
166
defaultRoute = true ;
168
167
}
169
168
170
- var fileSystem = new AzureFileSystem ( containerName , rootUrl , connectionString , max , defaultRoute ) ;
171
-
172
- if ( fileSystems == null )
173
- {
174
- fileSystems = new List < AzureFileSystem > { fileSystem } ;
175
- }
176
- else
177
- {
178
- fileSystems . Add ( fileSystem ) ;
179
- }
169
+ AzureFileSystem fileSystem = new AzureFileSystem ( containerName , rootUrl , connectionString , max , defaultRoute ) ;
170
+ FileSystems . Add ( fileSystem ) ;
180
171
}
181
172
182
- return fileSystems . SingleOrDefault ( fs => fs . ContainerName == containerName && fs . rootBlobUrl == rootUrl ) ;
173
+ return FileSystems . SingleOrDefault ( fs => fs . ContainerName == containerName && fs . rootBlobUrl == rootUrl ) ;
183
174
}
184
175
}
185
176
@@ -197,8 +188,8 @@ public void AddFile(string path, Stream stream, bool overrideIfExists)
197
188
198
189
if ( ! overrideIfExists && exists )
199
190
{
200
- InvalidOperationException error = new InvalidOperationException ( string . Format ( "File already exists at {0}" , blockBlob . Uri ) ) ;
201
- this . LogHelper . Error < AzureBlobFileSystem > ( string . Format ( "File already exists at {0}" , path ) , error ) ;
191
+ InvalidOperationException error = new InvalidOperationException ( $ "File already exists at { blockBlob . Uri } " ) ;
192
+ this . LogHelper . Error < AzureBlobFileSystem > ( $ "File already exists at { path } " , error ) ;
202
193
return ;
203
194
}
204
195
@@ -224,7 +215,7 @@ public void AddFile(string path, Stream stream, bool overrideIfExists)
224
215
blockBlob . Properties . ContentType = contentType ;
225
216
}
226
217
227
- blockBlob . Properties . CacheControl = string . Format ( "public, max-age={0}" , this . MaxDays * 86400 ) ;
218
+ blockBlob . Properties . CacheControl = $ "public, max-age={ this . MaxDays * 86400 } " ;
228
219
blockBlob . SetProperties ( ) ;
229
220
230
221
if ( created == DateTimeOffset . MinValue )
@@ -246,7 +237,7 @@ public void AddFile(string path, Stream stream, bool overrideIfExists)
246
237
}
247
238
catch ( Exception ex )
248
239
{
249
- this . LogHelper . Error < AzureBlobFileSystem > ( string . Format ( "Unable to upload file at {0}" , path ) , ex ) ;
240
+ this . LogHelper . Error < AzureBlobFileSystem > ( $ "Unable to upload file at { path } " , ex ) ;
250
241
}
251
242
}
252
243
@@ -305,7 +296,7 @@ public void DeleteDirectory(string path, bool recursive)
305
296
}
306
297
catch ( Exception ex )
307
298
{
308
- this . LogHelper . Error < AzureBlobFileSystem > ( string . Format ( "Unable to delete directory at {0}" , path ) , ex ) ;
299
+ this . LogHelper . Error < AzureBlobFileSystem > ( $ "Unable to delete directory at { path } " , ex ) ;
309
300
}
310
301
}
311
302
@@ -340,7 +331,7 @@ public void DeleteFile(string path)
340
331
}
341
332
catch ( Exception ex )
342
333
{
343
- this . LogHelper . Error < AzureBlobFileSystem > ( string . Format ( "Unable to delete file at {0}" , path ) , ex ) ;
334
+ this . LogHelper . Error < AzureBlobFileSystem > ( $ "Unable to delete file at { path } " , ex ) ;
344
335
}
345
336
}
346
337
@@ -601,10 +592,10 @@ private string ResolveUrl(string path, bool relative)
601
592
602
593
if ( this . UseDefaultRoute )
603
594
{
604
- return string . Format ( "/{0 }/{1}" , Constants . DefaultMediaRoute , fixedPath ) ;
595
+ return $ "/{ Constants . DefaultMediaRoute } /{ fixedPath } " ;
605
596
}
606
597
607
- return string . Format ( "/{0 }/{1}" , this . ContainerName , fixedPath ) ;
598
+ return $ "/{ this . ContainerName } /{ fixedPath } " ;
608
599
}
609
600
610
601
/// <summary>
0 commit comments