diff options
author | elaskavaia | 2016-12-05 19:53:54 +0000 |
---|---|---|
committer | Pascal Rapicault | 2017-01-09 20:36:03 +0000 |
commit | da7f4655df9e1902d89df28ee53e4f4b092f3c07 (patch) | |
tree | 707095d4c100362fbd3b1ae224b32d0f5c05a4ca | |
parent | 443952d76abd4a5d879276f2a5fe06bd915a3631 (diff) | |
download | rt.equinox.p2-da7f4655df9e1902d89df28ee53e4f4b092f3c07.tar.gz rt.equinox.p2-da7f4655df9e1902d89df28ee53e4f4b092f3c07.tar.xz rt.equinox.p2-da7f4655df9e1902d89df28ee53e4f4b092f3c07.zip |
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>
-rw-r--r-- | bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/BackupStore.java | 20 |
1 files changed, 12 insertions, 8 deletions
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 ed4c1e8b1..0e3ecc828 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 @@ public class BackupStore implements IBackupStore { * @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())); + } + } + } + // will attempt to delete before exists check to get rid of dead links + if (file.delete()) { + return true; } - return file.delete(); + // 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) { |