mirror of
https://github.com/taoneill/war.git
synced 2024-11-13 05:54:31 +01:00
Less complicated file numbering system
Closes gh-486. There will still be duplicate numbers when old versions are deleted, as the version only takes into account the number of old versions in the /temp/oldversion/warzone-x/ folder.
This commit is contained in:
parent
0557d94911
commit
520bac05da
@ -77,23 +77,8 @@ public class SaveZoneCommand extends AbstractZoneMakerCommand {
|
||||
oldVersionsFolder.mkdirs();
|
||||
|
||||
File[] versionFolders = oldVersionsFolder.listFiles();
|
||||
File last = null;
|
||||
if (versionFolders.length > 0) {
|
||||
last = versionFolders[versionFolders.length - 1];
|
||||
}
|
||||
|
||||
int oldVersion = 0;
|
||||
if (last != null) {
|
||||
// at least one version
|
||||
try {
|
||||
String numVersion = last.getName().split("-")[1]; // get rid of datetime prefix
|
||||
oldVersion = Integer.parseInt(numVersion);
|
||||
} catch (NumberFormatException badname) {
|
||||
War.war.log("Failed to read old version of warzone " + zone.getName(), Level.WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
int newVersion = oldVersion + 1;
|
||||
int newVersion = versionFolders.length + 1;
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String newVersionString = format.format(new Date()) + "-" + newVersion;
|
||||
String newVersionPath = War.war.getDataFolder().getPath() + "/temp/oldversions/warzone-" + zone.getName() + "/" + newVersionString;
|
||||
|
Loading…
Reference in New Issue
Block a user