Copilot commented on code in PR #18118:
URL: https://github.com/apache/iotdb/pull/18118#discussion_r3541235823
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/FileUtils.java:
##########
@@ -161,7 +179,16 @@ public static void deleteFileOrDirectoryWithRetry(File
file) {
}
public static void deleteDirectoryAndEmptyParent(File folder) {
- deleteFileOrDirectory(folder);
+ deleteDirectoryAndEmptyParent(folder, null);
+ }
+
+ public static void deleteDirectoryAndEmptyParentWithRateLimiter(
+ File folder, LongConsumer deleteRateLimiter) {
+ deleteDirectoryAndEmptyParent(folder, deleteRateLimiter);
+ }
+
+ private static void deleteDirectoryAndEmptyParent(File folder, LongConsumer
deleteRateLimiter) {
+ deleteFileOrDirectory(folder, false, deleteRateLimiter);
final File parentFolder = folder.getParentFile();
File[] files = parentFolder.listFiles();
if (parentFolder.isDirectory() && (files == null || files.length == 0)) {
Review Comment:
`deleteDirectoryAndEmptyParent(...)` assumes `folder.getParentFile()` is
non-null. If the caller passes a path with no parent component (e.g., `new
File("dir")` or a root path on some platforms), this will throw a
`NullPointerException` at `parentFolder.listFiles()`, aborting the delete flow.
Please guard against `parentFolder == null` (or treat it as "no parent to clean
up").
--
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]