Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/storage/azure-storage-blobs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### Bugs Fixed

- Empty file or existing file won't be created/overwritten if the blob to be downloaded doesn't exist.

### Other Changes

## 12.6.0-beta.1 (2022-08-09)
Expand Down
3 changes: 1 addition & 2 deletions sdk/storage/azure-storage-blobs/src/blob_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,6 @@ namespace Azure { namespace Storage { namespace Blobs {
firstChunkOptions.Range.Value().Length = firstChunkLength;
}

_internal::FileWriter fileWriter(fileName);

auto firstChunk = Download(firstChunkOptions, context);
const Azure::ETag eTag = firstChunk.Value.Details.ETag;

Expand Down Expand Up @@ -461,6 +459,7 @@ namespace Azure { namespace Storage { namespace Blobs {
}
};

_internal::FileWriter fileWriter(fileName);
bodyStreamToFile(*(firstChunk.Value.BodyStream), fileWriter, 0, firstChunkLength, context);
firstChunk.Value.BodyStream.reset();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,14 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_TRUE(exceptionCaught);
}

TEST_F(BlockBlobClientTest, DownloadNonExistingToFile) {
const auto testName(GetTestName());
auto blockBlobClient = GetBlockBlobClient(testName);

EXPECT_THROW(blockBlobClient.DownloadTo(testName), StorageException);
EXPECT_THROW(ReadFile(testName), std::runtime_error);
}

TEST_F(BlockBlobClientTest, DeleteIfExists)
{
auto const testName(GetTestName());
Expand Down
1 change: 1 addition & 0 deletions sdk/storage/azure-storage-files-datalake/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Bugs Fixed

- Fixed a bug where file/directory renaming cannot be authenticated with SAS.
- Empty file or existing file won't be created/overwritten if the file to be downloaded doesn't exist.

### Other Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,15 @@ namespace Azure { namespace Storage { namespace Test {
fileClient.Delete();
}

TEST_F(DataLakeFileClientTest, DownloadNonExistingToFile)
{
const auto testName(GetTestName());
auto fileClient = m_fileSystemClient->GetFileClient(testName);

EXPECT_THROW(fileClient.DownloadTo(testName), StorageException);
EXPECT_THROW(ReadFile(testName), std::runtime_error);
}

TEST_F(DataLakeFileClientTest, ScheduleForDeletion)
{
{
Expand Down
2 changes: 2 additions & 0 deletions sdk/storage/azure-storage-files-shares/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

### Bugs Fixed

- Empty file or existing file won't be created/overwritten if the file to be downloaded doesn't exist.

### Other Changes

## 12.2.1 (2022-03-09)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
firstChunkOptions.Range.Value().Length = firstChunkLength;
}

_internal::FileWriter fileWriter(fileName);

auto firstChunk = Download(firstChunkOptions, context);
const Azure::ETag etag = firstChunk.Value.Details.ETag;

Expand Down Expand Up @@ -845,6 +843,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
}
};

_internal::FileWriter fileWriter(fileName);
bodyStreamToFile(*(firstChunk.Value.BodyStream), fileWriter, 0, firstChunkLength, context);
firstChunk.Value.BodyStream.reset();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_NO_THROW(fileClient.DownloadTo(buff.data(), 0));
}

TEST_F(FileShareFileClientTest, DownloadNonExistingToFile)
{
const auto testName(GetTestName());
auto fileClient = m_fileShareDirectoryClient->GetFileClient(m_testName);

EXPECT_THROW(fileClient.DownloadTo(testName), StorageException);
EXPECT_THROW(ReadFile(testName), std::runtime_error);
}

TEST_F(FileShareFileClientTest, FileMetadata)
{
auto metadata1 = GetMetadata();
Expand Down