Skip to content

Commit

Permalink
Added accessTier check to download call for BlobHandler.ts to fail on…
Browse files Browse the repository at this point in the history
… archived blobs.

Azure#2473
  • Loading branch information
brendonkpss committed Oct 24, 2024
1 parent 1dd0784 commit 1179490
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
## Upcoming Release

Blob:

- GetBlob on Archive tier blobs now fails as expected.

## 2024.10 Version 3.33.0

General:
Expand Down
4 changes: 4 additions & 0 deletions src/blob/handlers/BlobHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ export default class BlobHandler extends BaseHandler implements IBlobHandler {
options.modifiedAccessConditions
);

if (blob.properties.accessTier === Models.AccessTier.Archive) {
throw StorageErrorFactory.getBlobArchived(context.contextId!);
}

if (blob.properties.blobType === Models.BlobType.BlockBlob) {
return this.downloadBlockBlobOrAppendBlob(options, context, blob);
} else if (blob.properties.blobType === Models.BlobType.PageBlob) {
Expand Down
16 changes: 16 additions & 0 deletions tests/blob/apis/blob.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,22 @@ describe("BlobAPIs", () => {
assert.fail();
});

it("download should not work when blob in Archive tier", async () => {
try {

const result = await blobClient.setAccessTier("Archive");
assert.equal(
result._response.request.headers.get("x-ms-client-request-id"),
result.clientRequestId
);
await blobClient.download(0);
} catch (error) {
assert.deepStrictEqual(error.statusCode, 409);
return;
}
assert.fail();
});

it("download should not work with conditional header ifUnmodifiedSince @loki @sql", async () => {
try {
await blobClient.download(0, undefined, {
Expand Down

0 comments on commit 1179490

Please sign in to comment.