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
Original file line number Diff line number Diff line change
Expand Up @@ -2169,6 +2169,8 @@ public OzoneFileStatus getOzoneFileStatus(String volumeName,
@Override
public void createDirectory(String volumeName, String bucketName,
String keyName) throws IOException {
verifyVolumeName(volumeName);
verifyBucketName(bucketName);
String ownerName = getRealUserInfo().getShortUserName();
OmKeyArgs keyArgs = new OmKeyArgs.Builder().setVolumeName(volumeName)
.setBucketName(bucketName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,24 +496,30 @@ public boolean createDirectory(String pathStr) throws IOException {
LOG.trace("creating dir for path: {}", pathStr);
incrementCounter(Statistic.OBJECTS_CREATED, 1);
OFSPath ofsPath = new OFSPath(pathStr, config);
if (ofsPath.getVolumeName().isEmpty()) {

String volumeName = ofsPath.getVolumeName();
if (volumeName.isEmpty()) {
// Volume name unspecified, invalid param, return failure
return false;
}
if (ofsPath.getBucketName().isEmpty()) {

String bucketName = ofsPath.getBucketName();
if (bucketName.isEmpty()) {
// Create volume only
objectStore.createVolume(ofsPath.getVolumeName());
objectStore.createVolume(volumeName);
return true;
}

String keyStr = ofsPath.getKeyName();
try {
OzoneBucket bucket = getBucket(ofsPath, true);
// Empty keyStr here indicates only volume and bucket is
// given in pathStr, so getBucket above should handle the creation
// of volume and bucket. We won't feed empty keyStr to
// bucket.createDirectory as that would be a NPE.
if (keyStr != null && keyStr.length() > 0) {
bucket.createDirectory(keyStr);
if (keyStr == null || keyStr.isEmpty()) {
// Empty keyStr here indicates only volume and bucket is
// given in pathStr, so getBucket above should handle the creation
// of volume and bucket. We won't feed empty keyStr to
// bucket.createDirectory as that would be a NPE.
getBucket(volumeName, bucketName, true);
} else {
proxy.createDirectory(volumeName, bucketName, keyStr);
Comment on lines +515 to +516

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this code expected to create both the bucket and the path? The code before would issue a redundant get bucket info if the bucket was already there but the new code will fail if the bucket is not present?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right, I missed that property of the getBucket call, I have changed the patch, to see if this was the only cause for the test failures. I will update the PR description once things settle about the new changes.

}
} catch (OMException e) {
if (e.getResult() == OMException.ResultCodes.FILE_ALREADY_EXISTS) {
Expand Down