Skip to content

Commit

Permalink
Fixed bug where DataLakeFileClient.Upload() could not upload read-onl…
Browse files Browse the repository at this point in the history
…y files. (#14864)
  • Loading branch information
seanmcc-msft authored Sep 3, 2020
1 parent 7aab376 commit 69cf78f
Show file tree
Hide file tree
Showing 9 changed files with 856 additions and 417 deletions.
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 @@ -2,6 +2,7 @@

## 12.5.0-preview.1 (Unreleased)
- Fixed bug where Stream returned from DataLakeFileClient.OpenWrite() did not flush while disposing preventing compatibility with using keyword.
- Fixed bug where DataLakeFileClient.Upload() could not upload read-only files.

## 12.4.0 (2020-08-31)
- Fixed bug where DataLakeFileClient.Upload() would deadlock if the content stream's position was not 0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3110,7 +3110,7 @@ public virtual Response<PathInfo> Upload(
StorageTransferOptions transferOptions = default,
CancellationToken cancellationToken = default)
{
using (FileStream stream = new FileStream(path, FileMode.Open))
using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
return StagedUploadInternal(
stream,
Expand Down Expand Up @@ -3226,7 +3226,7 @@ public virtual async Task<Response<PathInfo>> UploadAsync(
DataLakeFileUploadOptions options,
CancellationToken cancellationToken = default)
{
using (FileStream stream = new FileStream(path, FileMode.Open))
using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
return await StagedUploadInternal(
stream,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2861,7 +2861,9 @@ public async Task UploadAsync_FileLarge()
}

[Test]
public async Task UploadAsync_MinFile()
[TestCase(false)]
[TestCase(true)]
public async Task UploadAsync_MinFile(bool readOnlyFile)
{
// Arrange
await using DisposingFileSystem test = await GetNewFileSystem();
Expand All @@ -2878,12 +2880,18 @@ public async Task UploadAsync_MinFile()
{
File.WriteAllBytes(path, data);

if (readOnlyFile)
{
File.SetAttributes(path, FileAttributes.ReadOnly);
}

await file.UploadAsync(path);
}
finally
{
if (File.Exists(path))
{
File.SetAttributes(path, FileAttributes.Normal);
File.Delete(path);
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 69cf78f

Please sign in to comment.