From f71bec35e507d3b19655ffb1a68b5a83f57e0506 Mon Sep 17 00:00:00 2001 From: snowleo Date: Sun, 17 Apr 2011 00:08:09 +0000 Subject: [PATCH] [trunk] Throw errors on upgrade rename fail. git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1238 e251c2fe-e539-e718-e476-b85c1f46cddb --- .../src/com/earth2me/essentials/EssentialsUpgrade.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java b/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java index 8334dec27..e345a3839 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java @@ -38,7 +38,7 @@ public class EssentialsUpgrade { } removeLinesFromConfig(configFile,"\\s*#?\\s*worth-[0-9]+.*", "# Worth values have been moved to worth.yml"); } catch (Throwable e) { - logger.log(Level.WARNING, "Error while upgrading the files", e); + logger.log(Level.SEVERE, "Error while upgrading the files", e); } } @@ -70,8 +70,12 @@ public class EssentialsUpgrade { br.close(); bw.close(); if (needUpdate) { - file.renameTo(new File(file.getParentFile(), file.getName().concat("."+System.currentTimeMillis()+".upgradebackup"))); - tempFile.renameTo(file); + if (!file.renameTo(new File(file.getParentFile(), file.getName().concat("."+System.currentTimeMillis()+".upgradebackup")))) { + throw new Exception("Failed to move config.yml to backup location."); + } + if (!tempFile.renameTo(file)) { + throw new Exception("Failed to rename temp file to config.yml"); + } } } }