Skip to content

Fix for FileUtils.recursiveDelete() when dealing with symbolic links #3141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 15, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions arduino-core/src/processing/app/helpers/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static void recursiveDelete(File file) {
recursiveDelete(current);
}
}
deleteIfExists(file);
file.delete();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you deleted the .exists() check in deleteIfExists, could you still call that function instead of file.delete()? It uses a defensive approach checking if File is null

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's explained in the second commit: file is already checked for being not null, no need to check again
the check is here: https://github.com/arduino/Arduino/pull/3141/files#diff-fb3046d74e0c4a32b94edd584638ecd3L76

BTW if you prefer to keep the defensive approach and check anyway, just drop the second commit and keep only the first one!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed that. Thanks

}

public static File createTempFolder() throws IOException {
Expand Down Expand Up @@ -274,10 +274,6 @@ public static boolean deleteIfExists(File file) {
return true;
}

if (!file.exists()) {
return false;
}

return file.delete();
}

Expand Down