Fixing folder creation on Azure

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2010-12-18 22:30:28 +01:00
parent 4b5f2db33d
commit 39d7442014
2 changed files with 22 additions and 1 deletions

View File

@@ -165,6 +165,21 @@ namespace Orchard.Azure.Tests.FileSystems.Media {
Assert.AreEqual(1, _azureBlobStorageProvider.ListFiles("folder1/folder4/folder3").Count());
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void CannotCreateAlreadyExistingFolders()
{
_azureBlobStorageProvider.CreateFile("folder1/foo.txt");
_azureBlobStorageProvider.CreateFolder("folder1");
}
[Test]
public void CanCreateAlreadyExistingFolder()
{
_azureBlobStorageProvider.CreateFile("folder1/foo.txt");
_azureBlobStorageProvider.TryCreateFolder("folder1");
}
[Test]
public void ShouldReadWriteFiles() {
const string teststring = "This is a test string.";

View File

@@ -156,7 +156,13 @@ namespace Orchard.Azure {
public void TryCreateFolder(string path) {
EnsurePathIsRelative(path);
CreateFile(Combine(path, FolderEntry));
using (new HttpContextWeaver()) {
if (Container.DirectoryExists(String.Concat(_root, path))) {
return;
}
CreateFile(Combine(path, FolderEntry));
}
}
public void CreateFolder(string path) {