Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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