diff --git a/src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java b/src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java index d62050f41..fdaf6bc1d 100644 --- a/src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java +++ b/src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java @@ -408,7 +408,16 @@ private void storeContactList0() throws IOException out.close(); // note the end of the transfert - backup.renameTo(new File(contactlistFile.getName() + ".bak")); + File final_backup = new File(contactlistFile.getAbsolutePath() + + ".bak"); + + // this should not happen, but if it's the case, the rename + // operation can fail + if (final_backup.exists()) { + final_backup.delete(); + } + + backup.renameTo(final_backup); // really write the modification OutputStream stream = new FileOutputStream(contactlistFile); @@ -417,7 +426,7 @@ private void storeContactList0() throws IOException stream.close(); // once done, delete the backup file - backup.delete(); + final_backup.delete(); } }