Skip to content

Commit

Permalink
GH-38782: [C++][FS][Azure] Do nothing for CreateDir("/container", tru…
Browse files Browse the repository at this point in the history
…e) (#38783)

### Rationale for this change

It's failed with hierarchical namespace support. And we don't need to do nothing for the case because container must exist in the case.

### What changes are included in this PR?

Add a missing `location.path.empty()` check.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

Yes.
* Closes: #38782

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
  • Loading branch information
kou committed Nov 19, 2023
1 parent 46c226e commit 7df1cdd
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions cpp/src/arrow/filesystem/azurefs.cc
Expand Up @@ -708,16 +708,18 @@ class AzureFileSystem::Impl {
return Status::OK();
}

auto directory_client =
datalake_service_client_->GetFileSystemClient(location.container)
.GetDirectoryClient(location.path);
try {
directory_client.CreateIfNotExists();
} catch (const Azure::Storage::StorageException& exception) {
return internal::ExceptionToStatus(
"Failed to create a directory: " + location.path + " (" +
directory_client.GetUrl() + ")",
exception);
if (!location.path.empty()) {
auto directory_client =
datalake_service_client_->GetFileSystemClient(location.container)
.GetDirectoryClient(location.path);
try {
directory_client.CreateIfNotExists();
} catch (const Azure::Storage::StorageException& exception) {
return internal::ExceptionToStatus(
"Failed to create a directory: " + location.path + " (" +
directory_client.GetUrl() + ")",
exception);
}
}

return Status::OK();
Expand Down

0 comments on commit 7df1cdd

Please sign in to comment.