deniskuzZ commented on code in PR #3910: URL: https://github.com/apache/hive/pull/3910#discussion_r1081705466
########## ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/QueryCompactor.java: ########## @@ -245,16 +243,32 @@ private static void disableLlapCaching(HiveConf conf) { * @throws IOException the directory cannot be deleted * @throws HiveException the table is not found */ - static void cleanupEmptyDir(HiveConf conf, String tmpTableName) throws IOException, HiveException { + static void cleanupEmptyTableDir(HiveConf conf, String tmpTableName) + throws IOException, HiveException { org.apache.hadoop.hive.ql.metadata.Table tmpTable = Hive.get().getTable(tmpTableName); if (tmpTable != null) { - Path path = new Path(tmpTable.getSd().getLocation()); - FileSystem fs = path.getFileSystem(conf); + cleanupEmptyDir(conf, new Path(tmpTable.getSd().getLocation())); + } + } + + /** + * Remove the directory if it's empty. + * @param conf the Hive configuration + * @param path path of the directory + * @throws IOException if any IO error occurs + */ + static void cleanupEmptyDir(HiveConf conf, Path path) throws IOException { + FileSystem fs = path.getFileSystem(conf); + try { if (!fs.listFiles(path, false).hasNext()) { fs.delete(path, true); } + } catch (FileNotFoundException e) { + // Ignore the case when the dir was already removed + LOG.warn("Ignored exception during cleanup {}", path, e); Review Comment: 👍 -- 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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org