You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by "wecharyu (via GitHub)" <gi...@apache.org> on 2025/10/02 15:22:40 UTC
Re: [PR] HIVE-29117: Refactor deleteDir and moveToTrash [hive]
wecharyu commented on code in PR #6006:
URL: https://github.com/apache/hive/pull/6006#discussion_r2394782366
##########
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/FileUtils.java:
##########
@@ -71,41 +71,19 @@ public boolean accept(Path p) {
}
};
- /**
- * Move a particular file or directory to the trash.
- * @param fs FileSystem to use
- * @param f path of file or directory to move to trash.
- * @param conf configuration object
- * @return true if move successful
- * @throws IOException
- */
- public static boolean moveToTrash(FileSystem fs, Path f, Configuration conf, boolean purge)
+ public static boolean deleteDir(FileSystem fs, Path f, boolean ifPurge, Configuration conf)
throws IOException {
- LOG.debug("deleting " + f);
- boolean result;
+ if (!fs.exists(f)) {
+ LOG.warn("The path to delete does not exist: " + f);
+ return true;
+ }
+ if (!ifPurge && moveToTrash(fs, f, conf)) {
+ return true;
+ }
try {
- if (!fs.exists(f)) {
- LOG.warn("The path to moveToTrash does not exist: " + f);
- return true;
- }
- if (purge) {
- LOG.debug("purge is set to true. Not moving to Trash " + f);
- } else {
- result = Trash.moveToAppropriateTrash(fs, f, conf);
- if (result) {
- LOG.trace("Moved to trash: " + f);
- return true;
- }
- }
- } catch (IOException ioe) {
// for whatever failure reason including that trash has lower encryption zone
// retry with force delete
Review Comment:
Oh, we catch the `IOException` in `moveToTrash`, it would return false.
--
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-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org