Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTodor Boev2018-09-04 12:12:11 +0000
committerAlexander Kurtakov2018-09-06 09:35:18 +0000
commitd1f871da10232f21e402ca0f3dffeabd65d3e196 (patch)
tree343ad4ebd6816aa4e85ebfa49b32273d5f5071c2
parent96ff6451da1b4baa3b748afa2d2d3a343a654ffb (diff)
downloadrt.equinox.p2-d1f871da10232f21e402ca0f3dffeabd65d3e196.tar.gz
rt.equinox.p2-d1f871da10232f21e402ca0f3dffeabd65d3e196.tar.xz
rt.equinox.p2-d1f871da10232f21e402ca0f3dffeabd65d3e196.zip
Since File.exist() is not a reliable check it is performed not as a guard against deleting a non-existent file, but as confirmation that the deletion indeed failed because the file was not there. Change-Id: I77233458892083b3049c323cb004d97e195f475a Signed-off-by: Todor Boev <rinsvind@gmail.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/BackupStore.java10
1 files changed, 6 insertions, 4 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 fc877d926..a02815cec 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
@@ -113,12 +113,12 @@ public class BackupStore implements IBackupStore {
/**
* The name of the backup directory (no path - relative to the backup root).
*/
- private String backupName;
+ private final String backupName;
/**
* The name of a dummy file used to backup empty directories
*/
- private String dummyName;
+ private final String dummyName;
/**
* A server socket that is used to obtain a port (a shared resource on this machine)
@@ -143,7 +143,7 @@ public class BackupStore implements IBackupStore {
*/
private boolean closed;
- private Map<String, String> renamedInPlace = new HashMap<>();
+ private final Map<String, String> renamedInPlace = new HashMap<>();
/**
* Generates a BackupStore with a default prefix of ".p2bu" for backup directory and
@@ -284,7 +284,9 @@ public class BackupStore implements IBackupStore {
Util.copyStream(new FileInputStream(file), true, new FileOutputStream(buFile), true);
backupCounter++;
}
- if (file.exists() && !file.delete())
+
+ // File.exists() is not reliable so always attempt to delete first and check why it may have failed second.
+ if (!file.delete() && file.exists())
throw new IOException(NLS.bind(Messages.BackupStore_can_not_delete_after_copy_0, file));
}

Back to the top