From 956ddda98e599db3ce8b9c75a0a2fa7b85648cf7 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 14 May 2015 19:18:24 +0200 Subject: [PATCH 1/2] Removed buggy redundant check in FileUtils.deleteIfExists() The documentation for File.delete() says that the method return true if the the file is successfully deleted, otherwise false is returned. An exception is thrown only when the file is not accessible (for permission problem). Removing the extra check solves another problem, for example in a folder with the following situation: linkToFileA -> FileA FileA if we remove FileA, we remain with a broken link that can't be removed using FileUtils.deleteIfExists() because calling File.exists() on a broken link returns *false*. This commit solve this problem. --- arduino-core/src/processing/app/helpers/FileUtils.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arduino-core/src/processing/app/helpers/FileUtils.java b/arduino-core/src/processing/app/helpers/FileUtils.java index 99fb95031..be3f87728 100644 --- a/arduino-core/src/processing/app/helpers/FileUtils.java +++ b/arduino-core/src/processing/app/helpers/FileUtils.java @@ -274,10 +274,6 @@ public class FileUtils { return true; } - if (!file.exists()) { - return false; - } - return file.delete(); } From 971bd770585c4612604ceda3372a082d20ad946c Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 14 May 2015 19:36:37 +0200 Subject: [PATCH 2/2] Removed redundant call to File.deleteIfExists() file is already checked for being not null, no need to check again. --- arduino-core/src/processing/app/helpers/FileUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arduino-core/src/processing/app/helpers/FileUtils.java b/arduino-core/src/processing/app/helpers/FileUtils.java index be3f87728..186141cf5 100644 --- a/arduino-core/src/processing/app/helpers/FileUtils.java +++ b/arduino-core/src/processing/app/helpers/FileUtils.java @@ -85,7 +85,7 @@ public class FileUtils { recursiveDelete(current); } } - deleteIfExists(file); + file.delete(); } public static File createTempFolder() throws IOException {