#18257: Fixing HttpContent encapsulation while enumerating files

Work Item: 18257

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2011-12-02 12:54:39 -08:00
parent 20422a0f17
commit b0ab1f5dec
2 changed files with 21 additions and 8 deletions
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Web;
using NUnit.Framework;
using Orchard.Azure.FileSystems.Media;
using Microsoft.WindowsAzure;
@@ -243,5 +244,18 @@ namespace Orchard.Azure.Tests.FileSystems.Media {
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);
};
}
}
}
+7 -8
View File
@@ -108,14 +108,13 @@ namespace Orchard.Azure {
if ( !prefix.EndsWith("/") )
prefix += "/";
using ( new HttpContextWeaver() ) {
foreach (var blobItem in BlobClient.ListBlobsWithPrefix(prefix).OfType<CloudBlockBlob>()) {
// ignore directory entries
if(blobItem.Uri.AbsoluteUri.EndsWith(FolderEntry))
continue;
yield return new AzureBlobFileStorage(blobItem, _absoluteRoot);
}
using (new HttpContextWeaver()) {
return BlobClient
.ListBlobsWithPrefix(prefix)
.OfType<CloudBlockBlob>()
.Where(blobItem => !blobItem.Uri.AbsoluteUri.EndsWith(FolderEntry))
.Select(blobItem => new AzureBlobFileStorage(blobItem, _absoluteRoot))
.ToArray();
}
}