diff --git standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java index 6c17c86106..ccfdb656b7 100755 --- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java +++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java @@ -373,9 +373,9 @@ public void recycleDirToCmPath(Path f, boolean ifPurge) throws MetaException { } } - public boolean isEmpty(Path path) throws IOException, MetaException { - ContentSummary contents = getFs(path).getContentSummary(path); - if (contents != null && contents.getFileCount() == 0 && contents.getDirectoryCount() == 1) { + public boolean isEmptyDir(Path path) throws IOException, MetaException { + int listCount = getFs(path).listStatus(path).length; + if (listCount == 0) { return true; } return false; diff --git standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java index 7e97f8d9dd..ba759c855d 100644 --- standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java +++ standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java @@ -4604,7 +4604,7 @@ private static boolean isMustPurge(EnvironmentContext envContext, Table tbl) { private void deleteParentRecursive(Path parent, int depth, boolean mustPurge, boolean needRecycle) throws IOException, MetaException { if (depth > 0 && parent != null && wh.isWritable(parent)) { - if (wh.isDir(parent) && wh.isEmpty(parent)) { + if (wh.isDir(parent) && wh.isEmptyDir(parent)) { wh.deleteDir(parent, true, mustPurge, needRecycle); } deleteParentRecursive(parent.getParent(), depth - 1, mustPurge, needRecycle);