Bug 289518 - Logged backup store error on upgrade/revert of SDK

BackupStore has fullyDelete method. Unfortunately it does not work for
links very well
If we have lets say 2 files.
file1
file2 -> file1 (file2 is link to file1)

When this function runs file1 will be deleted, but file2 becomes dead
link, then
		if (!file.exists())
			return true;
That will return true for file2 even file is not deleted since exists
resolve links, so it leaves dead links in directory and whole thingy
fails

Change-Id: Id78f519907363e1439a35da55cf4174989971f01
Signed-off-by: elaskavaia <elaskavaia.cdt@gmail.com>
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/BackupStore.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/BackupStore.java
index ed4c1e8..0e3ecc8 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/BackupStore.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/BackupStore.java
@@ -571,17 +571,21 @@
 	 * @return true if, and only if the file is deleted without errors
 	 */
 	private boolean fullyDelete(File file) {
-		if (!file.exists())
-			return true;
 		if (file.isDirectory()) {
 			File[] children = file.listFiles();
-			if (children == null)
-				return false;
-			for (int i = 0; i < children.length; i++)
-				if (!fullyDelete(new File(file, children[i].getName())))
-					return false;
+			if (children != null) {
+				for (int i = 0; i < children.length; i++) {
+					// we will not stop even if some deletion failed
+					fullyDelete(new File(file, children[i].getName()));
+				}
+			}
 		}
-		return file.delete();
+		// will attempt to delete before exists check to get rid of dead links
+		if (file.delete()) {
+			return true;
+		}
+		// will return true if files does not actually exist even delete fails
+		return !file.exists();
 	}
 
 	private void restore(File root, File buRoot, Set<File> unrestorable) {