mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-03 12:03:51 +08:00
#18257: Fixing HttpContent encapsulation while enumerating files
Work Item: 18257 --HG-- branch : 1.x
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Web;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Orchard.Azure.FileSystems.Media;
|
using Orchard.Azure.FileSystems.Media;
|
||||||
using Microsoft.WindowsAzure;
|
using Microsoft.WindowsAzure;
|
||||||
@@ -243,5 +244,18 @@ namespace Orchard.Azure.Tests.FileSystems.Media {
|
|||||||
|
|
||||||
Assert.That(content, Is.EqualTo("fo"));
|
Assert.That(content, Is.EqualTo("fo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void HttpContextWeaverShouldBeDisposed()
|
||||||
|
{
|
||||||
|
_azureBlobStorageProvider.CreateFile("foo1.txt");
|
||||||
|
_azureBlobStorageProvider.CreateFile("foo2.txt");
|
||||||
|
_azureBlobStorageProvider.CreateFile("foo3.txt");
|
||||||
|
|
||||||
|
foreach(var f in _azureBlobStorageProvider.ListFiles(""))
|
||||||
|
{
|
||||||
|
Assert.That(HttpContext.Current, Is.Null);
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,14 +108,13 @@ namespace Orchard.Azure {
|
|||||||
if ( !prefix.EndsWith("/") )
|
if ( !prefix.EndsWith("/") )
|
||||||
prefix += "/";
|
prefix += "/";
|
||||||
|
|
||||||
using ( new HttpContextWeaver() ) {
|
using (new HttpContextWeaver()) {
|
||||||
foreach (var blobItem in BlobClient.ListBlobsWithPrefix(prefix).OfType<CloudBlockBlob>()) {
|
return BlobClient
|
||||||
// ignore directory entries
|
.ListBlobsWithPrefix(prefix)
|
||||||
if(blobItem.Uri.AbsoluteUri.EndsWith(FolderEntry))
|
.OfType<CloudBlockBlob>()
|
||||||
continue;
|
.Where(blobItem => !blobItem.Uri.AbsoluteUri.EndsWith(FolderEntry))
|
||||||
|
.Select(blobItem => new AzureBlobFileStorage(blobItem, _absoluteRoot))
|
||||||
yield return new AzureBlobFileStorage(blobItem, _absoluteRoot);
|
.ToArray();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user