Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug where DataLakeFileClient.Upload() could not upload read-onl… #14864

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
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