Fix bug where data migration from 1.8 would fail.

This commit is contained in:
Olof Larsson 2013-06-27 10:06:15 +02:00
parent 765e187bd1
commit 6339861819
3 changed files with 6 additions and 3 deletions

View File

@ -44,7 +44,10 @@ public class FactionColl extends Coll<Faction>
{ {
Faction ret = super.get(oid); Faction ret = super.get(oid);
if (ret == null) // We should only trigger automatic clean if the whole database system is initialized.
// A cleaning can only be successful if all data is available.
// Example Reason: When creating the special factions for the first time "createSpecialFactions" a clean would be triggered otherwise.
if (ret == null && Factions.get().isDatabaseInitialized())
{ {
String message = Txt.parse("<b>Non existing factionId <h>%s <b>requested. <i>Cleaning all boards and uplayers.", this.fixId(oid)); String message = Txt.parse("<b>Non existing factionId <h>%s <b>requested. <i>Cleaning all boards and uplayers.", this.fixId(oid));
Factions.get().log(message); Factions.get().log(message);

View File

@ -49,7 +49,7 @@ public class FactionColls extends XColls<FactionColl, Faction>
public void init() public void init()
{ {
super.init(); super.init();
this.migrate(); this.migrate();
} }

View File

@ -61,7 +61,7 @@ public class UPlayerColls extends XColls<UPlayerColl, UPlayer>
// Already migrated? // Already migrated?
if ( ! oldFile.exists()) return; if ( ! oldFile.exists()) return;
// Read the file content through GSON. // Read the file content through GSON.
Type type = new TypeToken<Map<String, UPlayer>>(){}.getType(); Type type = new TypeToken<Map<String, UPlayer>>(){}.getType();
Map<String, UPlayer> id2uplayer = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type); Map<String, UPlayer> id2uplayer = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type);