diff options
author | snowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-05-01 22:58:54 +0000 |
---|---|---|
committer | snowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-05-01 22:58:54 +0000 |
commit | 6f16650e7d4ccba542595e2223e7c93668f37a1d (patch) | |
tree | 991d39fbbb8209104bae9563caa23ceddd92362e | |
parent | c5850ddbd17b35af74c4bf675e3c01bd750d3843 (diff) | |
download | Essentials-6f16650e7d4ccba542595e2223e7c93668f37a1d.tar Essentials-6f16650e7d4ccba542595e2223e7c93668f37a1d.tar.gz Essentials-6f16650e7d4ccba542595e2223e7c93668f37a1d.tar.lz Essentials-6f16650e7d4ccba542595e2223e7c93668f37a1d.tar.xz Essentials-6f16650e7d4ccba542595e2223e7c93668f37a1d.zip |
[trunk] Upgrade:
- move users.yml to users.yml.old
- handle filesystems that ignore case
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1303 e251c2fe-e539-e718-e476-b85c1f46cddb
-rw-r--r-- | Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java b/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java index 7f9b5321f..3c40db8a8 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsUpgrade.java @@ -215,6 +215,7 @@ public class EssentialsUpgrade } } } + usersFile.renameTo(new File(usersFile.getAbsolutePath() + ".old")); } private void convertWarps() @@ -338,19 +339,24 @@ public class EssentialsUpgrade { continue; } - String sanitizedFilename = Util.sanitizeFileName(filename); + String sanitizedFilename = Util.sanitizeFileName(filename.substring(0, filename.length() - 4)) + ".yml"; if (sanitizedFilename.equals(filename)) { continue; } + File tmpFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename + ".tmp"); File newFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename); + if (!listOfFiles[i].renameTo(tmpFile)) { + logger.log(Level.WARNING, "Failed to move userdata/"+filename+" to userdata/"+sanitizedFilename+".tmp"); + continue; + } if (newFile.exists()) { logger.log(Level.WARNING, "Duplicated userdata: "+filename+" and "+sanitizedFilename); continue; } - if (!listOfFiles[i].renameTo(newFile)) { - logger.log(Level.WARNING, "Failed to move userdata/"+filename+" to userdata/"+sanitizedFilename); + if (!tmpFile.renameTo(newFile)) { + logger.log(Level.WARNING, "Failed to move userdata/"+sanitizedFilename+".tmp to userdata/"+sanitizedFilename); } } } |