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 root directory client could not be used to create files #7748

Merged
merged 2 commits into from
Jan 28, 2020
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
3 changes: 3 additions & 0 deletions sdk/storage/azure-storage-file-share/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release History

## 12.2.0-beta.1 (Unreleased)
- Fixed bug where ShareDirectoryAsyncClient.getFileClient appended an extra / for files in the root directory.

## 12.1.0 (2020-01-08)
This package's
[documentation](https://github.com/Azure/azure-sdk-for-java/blob/azure-storage-file_12.1.0/sdk/storage/azure-storage-file-share/README.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ public ShareServiceVersion getServiceVersion() {
*/
public ShareFileAsyncClient getFileClient(String fileName) {
String filePath = directoryPath + "/" + fileName;
if (directoryPath.isEmpty()) {
filePath = fileName;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment that this is to accommodate the root?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
return new ShareFileAsyncClient(azureFileStorageClient, shareName, filePath, null, accountName,
serviceVersion);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
package com.azure.storage.file.share

import com.azure.core.http.netty.NettyAsyncHttpClientBuilder
import com.azure.core.http.rest.Response
import com.azure.core.util.Context
import com.azure.storage.common.StorageSharedKeyCredential
import com.azure.storage.common.implementation.Constants
import com.azure.storage.file.share.models.NtfsFileAttributes
import com.azure.storage.file.share.models.ShareErrorCode
import com.azure.storage.file.share.models.ShareFileHttpHeaders
Expand Down Expand Up @@ -386,6 +389,16 @@ class ShareAPITests extends APISpec {
"fileName" | 1024 | null | Collections.singletonMap("", "value") | ShareErrorCode.EMPTY_METADATA_KEY
}

def "Create file in root directory"() {
given:
primaryShareClient.create()
def directoryClient = primaryShareClient.getRootDirectoryClient()

expect:
FileTestHelper.assertResponseStatusCode(
directoryClient.createFileWithResponse("testCreateFile", 1024, null, null, null, null, null, null), 201)
}

def "Delete directory"() {
given:
def directoryName = "testCreateDirectory"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"networkCallRecords" : [ {
"Method" : "PUT",
"Uri" : "http://gaprastg71.file.core.windows.net/shareapitestscreatefileinrootdirectory0432183cec74f?restype=share",
"Headers" : {
"x-ms-version" : "2019-02-02",
"User-Agent" : "azsdk-java-azure-storage-file-share/12.2.0-beta.1 (11.0.4; Windows 10 10.0)",
"x-ms-client-request-id" : "d83ba1d1-f731-4c5d-9b31-b307fa8bf6d4"
},
"Response" : {
"x-ms-version" : "2019-02-02",
"Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0",
"ETag" : "0x8D7A36E16B4FD84",
"Last-Modified" : "Mon, 27 Jan 2020 21:15:51 GMT",
"retry-after" : "0",
"Content-Length" : "0",
"StatusCode" : "201",
"x-ms-request-id" : "4d3fde2d-201a-0001-7856-d5cde7000000",
"Date" : "Mon, 27 Jan 2020 21:15:51 GMT",
"x-ms-client-request-id" : "d83ba1d1-f731-4c5d-9b31-b307fa8bf6d4"
},
"Exception" : null
}, {
"Method" : "PUT",
"Uri" : "http://gaprastg71.file.core.windows.net/shareapitestscreatefileinrootdirectory0432183cec74f/testCreateFile",
"Headers" : {
"x-ms-version" : "2019-02-02",
"User-Agent" : "azsdk-java-azure-storage-file-share/12.2.0-beta.1 (11.0.4; Windows 10 10.0)",
"x-ms-client-request-id" : "0530f34d-7eee-4941-a8f3-7465c4b0ca39"
},
"Response" : {
"x-ms-version" : "2019-02-02",
"x-ms-file-permission-key" : "15729343842853002337*8280205063999649007",
"x-ms-file-id" : "13835128424026341376",
"Server" : "Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-file-creation-time" : "2020-01-27T21:15:52.0821414Z",
"Last-Modified" : "Mon, 27 Jan 2020 21:15:52 GMT",
"retry-after" : "0",
"StatusCode" : "201",
"x-ms-request-server-encrypted" : "true",
"Date" : "Mon, 27 Jan 2020 21:15:51 GMT",
"ETag" : "0x8D7A36E16D23CA6",
"x-ms-file-attributes" : "Archive",
"x-ms-file-change-time" : "2020-01-27T21:15:52.0821414Z",
"x-ms-file-parent-id" : "0",
"Content-Length" : "0",
"x-ms-request-id" : "4d3fde3c-201a-0001-0156-d5cde7000000",
"x-ms-client-request-id" : "0530f34d-7eee-4941-a8f3-7465c4b0ca39",
"x-ms-file-last-write-time" : "2020-01-27T21:15:52.0821414Z"
},
"Exception" : null
} ],
"variables" : [ "shareapitestscreatefileinrootdirectory0432183cec74f" ]
}