File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed
UmbracoFileSystemProviders.Azure.Tests
UmbracoFileSystemProviders.Azure Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -639,13 +639,17 @@ public void TestGetSubDirectoriesNone()
639639 // Arrange
640640 AzureBlobFileSystem provider = this . CreateAzureBlobFileSystem ( containerName : "forms-data" ) ;
641641 provider . AddFile ( "forms/b5e2fab3-040d-4328-ac74-cf7f7ebe3918.json" , Stream . Null ) ;
642+ provider . AddFile ( "workflows/b5e2fab3-040d-4328-ac74-cf7f7ebe3918.json" , Stream . Null ) ;
642643
643644 // Act
644645 IEnumerable < string > actual = provider . GetDirectories ( "forms" ) ;
645646
646647 // Assert
647648 string [ ] expected = { } ;
648649 Assert . IsTrue ( expected . SequenceEqual ( actual ) ) ;
650+
651+ // Tidy up after test
652+ provider . DeleteDirectory ( "forms" ) ;
649653 }
650654 }
651655}
Original file line number Diff line number Diff line change @@ -518,12 +518,13 @@ public IEnumerable<string> GetDirectories(string path)
518518 var directory = this . GetDirectoryReference ( path ) ;
519519
520520 var listedBlobs = directory . ListBlobs ( ) ;
521- var prefixes = listedBlobs . Where ( blob => blob . IsPrefix ) . Select ( x=> x . Prefix ) . ToList ( ) ;
522- var blobPrefixes = listedBlobs . Where ( x => x . IsBlob && x . Blob . Name . LastIndexOf ( '/' ) >= 0 ) . Select ( x => x . Blob . Name . Substring ( 0 , x . Blob . Name . LastIndexOf ( '/' ) + 1 ) ) ;
523-
524-
521+ var prefixes = listedBlobs . Where ( blob => blob . IsPrefix ) . Select ( x => x . Prefix ) . ToList ( ) ;
522+ var blobPrefixes = listedBlobs . Where ( x => x . IsBlob && x . Blob . Name . LastIndexOf ( '/' ) >= 0 )
523+ . Select ( x => x . Blob . Name . Substring ( 0 , x . Blob . Name . LastIndexOf ( '/' ) + 1 ) ) ;
524+
525525 // Always get last segment for media sub folder simulation. E.g 1001, 1002
526- var all = prefixes . Union ( blobPrefixes ) ;
526+ var all = prefixes . Union ( blobPrefixes ) . Where ( x => ! x . Equals ( path + "/" ) ) ;
527+
527528 return all . Select ( cd => cd . TrimEnd ( '/' ) ) ;
528529 }
529530
@@ -853,7 +854,7 @@ private AzureBlobDirectory GetDirectoryReference(string path)
853854 Current . Logger . Debug < AzureBlobFileSystem > ( $ "GetDirectoryReference(path) method executed with path:{ path } ") ;
854855
855856 string blobPath = this . FixPath ( path ) ;
856- return new AzureBlobDirectory ( cloudBlobContainer , blobPath ) ;
857+ return new AzureBlobDirectory ( cloudBlobContainer , blobPath ) ;
857858 }
858859
859860 /// <summary>
You can’t perform that action at this time.
0 commit comments