Skip to content

Commit 0fc210d

Browse files
committed
move common code outside of if-else
1 parent 43db5f3 commit 0fc210d

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

src/Storage/Storage.Management/StorageAccount/RestoreAzStorageBlobRange.cs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,20 @@ public override void ExecuteCmdlet()
121121

122122
if (ShouldProcess(this.StorageAccountName, "Restore Blob Range"))
123123
{
124+
Track2.StorageAccountResource account = this.StorageClientTrack2.GetStorageAccount(this.ResourceGroupName, this.StorageAccountName);
125+
var restoreLro = account.RestoreBlobRanges(
126+
WaitUntil.Started,
127+
new Track2Models.BlobRestoreContent(
128+
this.TimeToRestore.ToUniversalTime(),
129+
PSBlobRestoreRange.ParseBlobRestoreRanges(this.BlobRestoreRange)));
130+
131+
// This is a temporary workaround of SDK issue https://github.com/Azure/azure-sdk-for-net/issues/29060
132+
// The workaround is to get the raw response and parse it into the output desired
133+
// The Blob restore status should be got from SDK directly once the issue is fixed
134+
Dictionary<string, object> temp = restoreLro.GetRawResponse().Content.ToObjectFromJson() as Dictionary<string, object>;
135+
124136
if (waitForComplete)
125137
{
126-
Track2.StorageAccountResource account = this.StorageClientTrack2.GetStorageAccount(this.ResourceGroupName, this.StorageAccountName);
127-
var restoreLro = account.RestoreBlobRanges(
128-
WaitUntil.Started,
129-
new Track2Models.BlobRestoreContent(
130-
this.TimeToRestore,
131-
PSBlobRestoreRange.ParseBlobRestoreRanges(this.BlobRestoreRange))
132-
);
133-
134-
// This is a temporary workaround of SDK issue https://github.com/Azure/azure-sdk-for-net/issues/29060
135-
// The workaround is to get the raw response and parse it into the output desired
136-
// The Blob restore status should be got from SDK directly once the issue is fixed
137-
Dictionary<string, object> temp = restoreLro.GetRawResponse().Content.ToObjectFromJson() as Dictionary<string, object>;
138-
139138
if (temp == null)
140139
{
141140
throw new InvalidJobStateException("Could not fetch the Blob restore response.");
@@ -162,14 +161,6 @@ public override void ExecuteCmdlet()
162161
}
163162
else
164163
{
165-
Track2.StorageAccountResource account = this.StorageClientTrack2.GetStorageAccount(this.ResourceGroupName, this.StorageAccountName);
166-
var restoreLro = account.RestoreBlobRanges(
167-
WaitUntil.Started,
168-
new Track2Models.BlobRestoreContent(
169-
this.TimeToRestore.ToUniversalTime(),
170-
PSBlobRestoreRange.ParseBlobRestoreRanges(this.BlobRestoreRange)));
171-
Dictionary<string, object> temp = restoreLro.GetRawResponse().Content.ToObjectFromJson() as Dictionary<string, object>;
172-
173164
if (temp == null)
174165
{
175166
throw new InvalidJobStateException("Could not fetch the Blob restore response.");

0 commit comments

Comments
 (0)