anmolanmol1234 commented on code in PR #7353:
URL: https://github.com/apache/hadoop/pull/7353#discussion_r1943343123


##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsBlobClient.java:
##########
@@ -555,58 +545,254 @@ public AbfsRestOperation createPath(final String path,
     final AbfsRestOperation op = getAbfsRestOperation(
         AbfsRestOperationType.PutBlob,
         HTTP_METHOD_PUT, url, requestHeaders);
+    op.execute(tracingContext);
+    return op;
+  }
+
+  /**
+   * Checks if the specified path is a directory by listing its contents.
+   *
+   * @param path the path to check.
+   * @param tracingContext the tracing context for the service call.
+   * @return true if the path is a directory and contains entries, false 
otherwise.
+   * @throws AzureBlobFileSystemException if the rest operation fails.
+   */
+  private boolean checkDirectoryByList(String path,
+      TracingContext tracingContext)
+      throws AzureBlobFileSystemException {
+    AbfsRestOperation listPathOp = listPath(path, false, 1, null,
+        tracingContext, false);
+    AbfsHttpOperation listPathResult = listPathOp.getResult();
+    if (listPathResult != null) {
+      // Determine if the path is a directory by checking if the list result 
schema has any paths
+      return !listPathResult.getListResultSchema().paths().isEmpty();
+    }
+    return false;
+  }
+
+  /**
+   * Checks if the specified path exists as a directory.
+   *
+   * @param path the path of the directory to check.
+   * @param tracingContext the tracing context for the service call.
+   * @return true if the directory exists, false otherwise.
+   * @throws AzureBlobFileSystemException if the rest operation fails.
+   */
+  private boolean checkForDirectoryExistence(String path,
+      TracingContext tracingContext)
+      throws AzureBlobFileSystemException {
+    // Check if the directory contains any entries by listing its contents.
+    if (checkDirectoryByList(path, tracingContext)) {

Review Comment:
   We dont want or condition here, we first want to check for dir using list 
and if that doesnt return entries only then we want to check for empty explicit 
dir, hence sequential flow



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to