Skip to content

Commit

Permalink
Fixes #28: Ensure CloudBlobClient.GetBlobReferenceFromServer() is cal…
Browse files Browse the repository at this point in the history
…led inside the try/catch block that handles StorageException.
  • Loading branch information
JaredReisinger committed Dec 11, 2013
1 parent ebc3b94 commit f0b942c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions Plugins/AzureReader2/AzureFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ public AzureFile(string blobName, AzureVirtualPathProvider parentProvider) : bas
public override System.IO.Stream Open() {
// Prefix already stripped from virtual path

// Get a reference to the blob
// mb: 12/8/2012 - the path needs to be a uri now, so combining blobclient baseuri with the virtualpath
Uri blobUri = new Uri(string.Format("{0}/{1}", parent.CloudBlobClient.BaseUri.OriginalString.TrimEnd('/', '\\'), VirtualPath));
ICloudBlob cloudBlob = parent.CloudBlobClient.GetBlobReferenceFromServer(blobUri);

MemoryStream ms = new MemoryStream(4096); // 4kb is a good starting point.

// Synchronously download
try {
// Get a reference to the blob
// mb: 12/8/2012 - the path needs to be a uri now, so combining blobclient baseuri with the virtualpath
Uri blobUri = new Uri(string.Format("{0}/{1}", parent.CloudBlobClient.BaseUri.OriginalString.TrimEnd('/', '\\'), VirtualPath));
ICloudBlob cloudBlob = parent.CloudBlobClient.GetBlobReferenceFromServer(blobUri);

cloudBlob.DownloadToStream(ms);
}
catch (StorageException e) {
Expand Down
14 changes: 7 additions & 7 deletions Plugins/AzureReader2/AzureVirtualPathProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ public bool FileExists(string virtualPath, System.Collections.Specialized.NameVa
if (IsPathVirtual(virtualPath)) {
if (LazyExistenceCheck) return true;

// Strip prefix from virtual path; keep container and blob
// mb:12/8/2012 - need to prepend the blob client base uri to the url
string relativeBlobURL = string.Format("{0}/{1}",CloudBlobClient.BaseUri.OriginalString.TrimEnd('/', '\\'), virtualPath.Substring(VirtualFilesystemPrefix.Length).Trim('/', '\\'));
try {
// Strip prefix from virtual path; keep container and blob
// mb:12/8/2012 - need to prepend the blob client base uri to the url
string relativeBlobURL = string.Format("{0}/{1}", CloudBlobClient.BaseUri.OriginalString.TrimEnd('/', '\\'), virtualPath.Substring(VirtualFilesystemPrefix.Length).Trim('/', '\\'));

// Get a reference to the blob
// mb:12/8/2012 - this call now must be a uri
ICloudBlob cloudBlob = CloudBlobClient.GetBlobReferenceFromServer(new Uri(relativeBlobURL));
// Get a reference to the blob
// mb:12/8/2012 - this call now must be a uri
ICloudBlob cloudBlob = CloudBlobClient.GetBlobReferenceFromServer(new Uri(relativeBlobURL));

try {
cloudBlob.FetchAttributes();
return true;
} catch (StorageException e) {
Expand Down

0 comments on commit f0b942c

Please sign in to comment.