Skip to content

Commit 3ef89e1

Browse files
added comments
1 parent cb70144 commit 3ef89e1

File tree

1 file changed

+9
-3
lines changed
  • hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services

1 file changed

+9
-3
lines changed

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsBlobClient.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,19 +513,25 @@ public AbfsRestOperation createPath(final String path,
513513
if (isFileCreation) {
514514
AbfsRestOperation statusOp = null;
515515
try {
516-
statusOp = getPathStatus(path,
517-
false, tracingContext, null);
516+
// Check if the file already exists by calling GetPathStatus
517+
statusOp = getPathStatus(path, false, tracingContext, null);
518518
} catch (AbfsRestOperationException ex) {
519+
// If the path does not exist, continue with file creation
520+
// For other errors, rethrow the exception
519521
if (ex.getStatusCode() != HTTP_NOT_FOUND) {
520522
throw ex;
521523
}
522524
}
525+
526+
// If the file exists and overwrite is not allowed, throw conflict
523527
if (statusOp != null && statusOp.hasResult() && !overwrite) {
524-
throw new AbfsRestOperationException(HTTP_CONFLICT,
528+
throw new AbfsRestOperationException(
529+
HTTP_CONFLICT,
525530
AzureServiceErrorCode.PATH_CONFLICT.getErrorCode(),
526531
PATH_EXISTS,
527532
null);
528533
} else {
534+
// Proceed with file creation (force overwrite = true)
529535
op = createFile(path, true, permissions, isAppendBlob, eTag,
530536
contextEncryptionAdapter, tracingContext);
531537
}

0 commit comments

Comments
 (0)