Github user manishgupta88 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2868#discussion_r229578798
--- Diff:
core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java ---
@@ -300,40 +300,27 @@ public static void deleteFoldersAndFiles(final
File... path)
@Override public Void run() throws Exception {
for (int i = 0; i < path.length; i++) {
- deleteRecursive(path[i]);
+ CarbonFile carbonFile =
FileFactory.getCarbonFile(path[i].getAbsolutePath());
+ boolean delete = carbonFile.delete();
+ if (!delete) {
+ throw new IOException("Error while deleting the folders and
files");
+ }
}
return null;
}
});
}
- /**
- * Recursively delete the files
- *
- * @param f File to be deleted
- * @throws IOException
- */
- private static void deleteRecursive(File f) throws IOException {
- if (f.isDirectory()) {
- File[] files = f.listFiles();
- if (null != files) {
- for (File c : files) {
- deleteRecursive(c);
- }
- }
- }
- if (f.exists() && !f.delete()) {
- throw new IOException("Error while deleting the folders and files");
- }
- }
-
public static void deleteFoldersAndFiles(final CarbonFile... file)
throws IOException, InterruptedException {
UserGroupInformation.getLoginUser().doAs(new
PrivilegedExceptionAction<Void>() {
@Override public Void run() throws Exception {
for (int i = 0; i < file.length; i++) {
- deleteRecursive(file[i]);
+ boolean delete = file[i].delete();
+ if (!delete) {
+ throw new IOException("Error while deleting the folders and
files");
--- End diff --
ok
---