Skip to content

Commit 9299f5f

Browse files
committed
Merge branch 'develop-version-3' into main-version-3
2 parents fe8505f + 5969755 commit 9299f5f

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/UmbracoFileSystemProviders.Azure/AzureFileSystem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,15 +814,15 @@ public BlobClient GetBlockBlobReference(string path)
814814
{
815815
Current.Logger.Debug<AzureBlobFileSystem>($"GetBlockBlobReference(path) method executed with path:{path}");
816816

817-
string blobPath = this.FixPath(path);
818-
819817
// Only make the request if there is an actual path. See issue 8.
820818
// https://github.com/JimBobSquarePants/UmbracoFileSystemProviders.Azure/issues/8
821819
if (string.IsNullOrWhiteSpace(path))
822820
{
823821
return null;
824822
}
825823

824+
string blobPath = this.FixPath(path);
825+
826826
try
827827
{
828828
return this.cloudBlobContainer.GetBlobClient(blobPath);

src/UmbracoFileSystemProviders.Azure/FileSystemVirtualFile.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ namespace Our.Umbraco.FileSystemProviders.Azure
99
using System.IO;
1010
using System.Web;
1111
using System.Web.Hosting;
12-
using global::Umbraco.Core.Composing;
1312
using global::Umbraco.Core.IO;
1413

1514
/// <summary>
1615
/// Represents a file object in a virtual file.
1716
/// </summary>
1817
internal class FileSystemVirtualFile : VirtualFile
1918
{
19+
/// <summary>
20+
/// The file system.
21+
/// </summary>
22+
private readonly IFileSystem fileSystem;
23+
2024
/// <summary>
2125
/// The stream function delegate.
2226
/// </summary>
@@ -40,7 +44,9 @@ public FileSystemVirtualFile(string virtualPath, Lazy<IFileSystem> fileSystem, s
4044
throw new ArgumentNullException(nameof(fileSystem));
4145
}
4246

43-
this.stream = () => fileSystem.Value.OpenFile(fileSystemPath);
47+
this.fileSystem = fileSystem.Value;
48+
49+
this.stream = () => this.fileSystem.OpenFile(fileSystemPath);
4450
}
4551

4652
/// <summary>
@@ -69,14 +75,19 @@ public override Stream Open()
6975
// Add Accept-Ranges header to fix videos not playing on Safari
7076
HttpContext.Current.Response.AppendHeader("Accept-Ranges", "bytes");
7177

72-
IFileSystem azureBlobFileSystem = Current.MediaFileSystem.Unwrap();
73-
int maxDays = ((AzureBlobFileSystem)azureBlobFileSystem).FileSystem.MaxDays;
78+
var unwrappedFileSystem = this.fileSystem.Unwrap();
79+
if (!(unwrappedFileSystem is AzureFileSystem azureFileSystem))
80+
{
81+
azureFileSystem = ((AzureBlobFileSystem)this.fileSystem).FileSystem;
82+
}
7483

84+
int maxDays = azureFileSystem.MaxDays;
7585
cache.SetExpires(DateTime.Now.ToUniversalTime().AddDays(maxDays));
7686
cache.SetMaxAge(new TimeSpan(maxDays, 0, 0, 0));
7787
cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
78-
cache.SetLastModified(azureBlobFileSystem.GetLastModified(VirtualPath).DateTime);
79-
var etag = ((AzureBlobFileSystem)azureBlobFileSystem).FileSystem.GetETag(VirtualPath);
88+
cache.SetLastModified(azureFileSystem.GetLastModified(VirtualPath).DateTime);
89+
90+
var etag = azureFileSystem.GetETag(VirtualPath);
8091
if (!string.IsNullOrWhiteSpace(etag))
8192
{
8293
cache.SetETag(etag);

0 commit comments

Comments
 (0)