Skip to content

Commit a1f030b

Browse files
Merge branch 'refs/heads/pr/53' into develop
2 parents 320fc48 + e1dbd2e commit a1f030b

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

src/UmbracoFileSystemProviders.Azure/AzureBlobFileSystem.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,20 @@ public AzureBlobFileSystem(string containerName, string rootUrl, string connecti
6363
/// <param name="useDefaultRoute">Whether to use the default "media" route in the url independent of the blob container.</param>
6464
public AzureBlobFileSystem(string containerName, string rootUrl, string connectionString, string maxDays, string useDefaultRoute)
6565
{
66-
this.FileSystem = AzureFileSystem.GetInstance(containerName, rootUrl, connectionString, maxDays, useDefaultRoute);
66+
bool useDefaultRouteParsed;
67+
int maxDaysParsed;
68+
69+
if (int.TryParse(maxDays, out maxDaysParsed) == false)
70+
{
71+
throw new ArgumentException(string.Format("Argument maxDays with value {0} could be converted from string to int", maxDays));
72+
}
73+
74+
if (bool.TryParse(useDefaultRoute, out useDefaultRouteParsed) == false)
75+
{
76+
throw new ArgumentException(string.Format("Argument useDefaultRoute with value {0} could be converted from string to bool", useDefaultRoute));
77+
}
78+
79+
this.FileSystem = new AzureFileSystem(containerName, rootUrl, connectionString, maxDaysParsed, useDefaultRouteParsed);
6780
}
6881

6982
/// <summary>

src/UmbracoFileSystemProviders.Azure/AzureFileSystem.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ internal class AzureFileSystem : IFileSystem
4141
private static readonly object Locker = new object();
4242

4343
/// <summary>
44-
/// The singleton instance of <see cref="AzureFileSystem"/>.
44+
/// A list of <see cref="AzureFileSystem"/>.
4545
/// </summary>
46-
private static AzureFileSystem fileSystem;
46+
private static List<AzureFileSystem> fileSystems;
4747

4848
/// <summary>
4949
/// The root url.
@@ -66,7 +66,7 @@ internal class AzureFileSystem : IFileSystem
6666
/// <exception cref="ArgumentNullException">
6767
/// Thrown if <paramref name="containerName"/> is null or whitespace.
6868
/// </exception>
69-
private AzureFileSystem(string containerName, string rootUrl, string connectionString, int maxDays, bool useDefaultRoute)
69+
internal AzureFileSystem(string containerName, string rootUrl, string connectionString, int maxDays, bool useDefaultRoute)
7070
{
7171
if (string.IsNullOrWhiteSpace(containerName))
7272
{
@@ -149,11 +149,11 @@ private AzureFileSystem(string containerName, string rootUrl, string connectionS
149149
/// <param name="maxDays">The maximum number of days to cache blob items for in the browser.</param>
150150
/// <param name="useDefaultRoute">Whether to use the default "media" route in the url independent of the blob container.</param>
151151
/// <returns>The <see cref="AzureFileSystem"/></returns>
152-
public static AzureFileSystem GetInstance(string containerName, string rootUrl, string connectionString, string maxDays, string useDefaultRoute)
152+
public AzureFileSystem GetInstance(string containerName, string rootUrl, string connectionString, string maxDays, string useDefaultRoute)
153153
{
154154
lock (Locker)
155155
{
156-
if (fileSystem == null)
156+
if (fileSystems.SingleOrDefault(fs => fs.ContainerName == containerName && fs.rootUrl == rootUrl) == null)
157157
{
158158
int max;
159159
if (!int.TryParse(maxDays, out max))
@@ -167,10 +167,19 @@ public static AzureFileSystem GetInstance(string containerName, string rootUrl,
167167
defaultRoute = true;
168168
}
169169

170-
fileSystem = new AzureFileSystem(containerName, rootUrl, connectionString, max, defaultRoute);
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+
}
171180
}
172181

173-
return fileSystem;
182+
return fileSystems.SingleOrDefault(fs => fs.ContainerName == containerName && fs.rootUrl == rootUrl);
174183
}
175184
}
176185

0 commit comments

Comments
 (0)