Bug Fix: Database boot.
Fixed: Having an orphaned subdivision (a rare situation) leads to most or all claims being lost.
This commit is contained in:
parent
a312b2e50d
commit
1350cf6ea3
|
|
@ -217,14 +217,18 @@ public class DatabaseDataStore extends DataStore
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//problematic claims will be removed from secondary storage, and never added to in-memory data store
|
||||||
|
boolean removeClaim = false;
|
||||||
|
|
||||||
long parentId = results.getLong("parentid");
|
long parentId = results.getLong("parentid");
|
||||||
long claimID = results.getLong("id");
|
long claimID = results.getLong("id");
|
||||||
|
|
||||||
Location lesserBoundaryCorner = null;
|
Location lesserBoundaryCorner = null;
|
||||||
Location greaterBoundaryCorner = null;
|
Location greaterBoundaryCorner = null;
|
||||||
|
String lesserCornerString = "(location not available)";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String lesserCornerString = results.getString("lessercorner");
|
lesserCornerString = results.getString("lessercorner");
|
||||||
lesserBoundaryCorner = this.locationFromString(lesserCornerString);
|
lesserBoundaryCorner = this.locationFromString(lesserCornerString);
|
||||||
|
|
||||||
String greaterCornerString = results.getString("greatercorner");
|
String greaterCornerString = results.getString("greatercorner");
|
||||||
|
|
@ -234,10 +238,8 @@ public class DatabaseDataStore extends DataStore
|
||||||
{
|
{
|
||||||
if(e.getMessage().contains("World not found"))
|
if(e.getMessage().contains("World not found"))
|
||||||
{
|
{
|
||||||
Claim claim = new Claim();
|
removeClaim = true;
|
||||||
claim.id = claimID;
|
GriefPrevention.AddLogEntry("Removing a claim in a world which does not exist: " + lesserCornerString);
|
||||||
claimsToRemove.add(claim);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -294,7 +296,11 @@ public class DatabaseDataStore extends DataStore
|
||||||
|
|
||||||
Claim claim = new Claim(lesserBoundaryCorner, greaterBoundaryCorner, ownerID, builderNames, containerNames, accessorNames, managerNames, claimID);
|
Claim claim = new Claim(lesserBoundaryCorner, greaterBoundaryCorner, ownerID, builderNames, containerNames, accessorNames, managerNames, claimID);
|
||||||
|
|
||||||
if(parentId == -1)
|
if(removeClaim)
|
||||||
|
{
|
||||||
|
claimsToRemove.add(claim);
|
||||||
|
}
|
||||||
|
else if(parentId == -1)
|
||||||
{
|
{
|
||||||
//top level claim
|
//top level claim
|
||||||
this.addClaim(claim, false);
|
this.addClaim(claim, false);
|
||||||
|
|
@ -321,6 +327,7 @@ public class DatabaseDataStore extends DataStore
|
||||||
if(topLevelClaim == null)
|
if(topLevelClaim == null)
|
||||||
{
|
{
|
||||||
claimsToRemove.add(childClaim);
|
claimsToRemove.add(childClaim);
|
||||||
|
GriefPrevention.AddLogEntry("Removing orphaned claim subdivision: " + childClaim.getLesserBoundaryCorner().toString());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -448,17 +455,21 @@ public class DatabaseDataStore extends DataStore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//deletes a top level claim from the database
|
//deletes a claim from the database
|
||||||
@Override
|
@Override
|
||||||
synchronized void deleteClaimFromSecondaryStorage(Claim claim)
|
synchronized void deleteClaimFromSecondaryStorage(Claim claim)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.refreshDataConnection();
|
this.refreshDataConnection();
|
||||||
|
|
||||||
|
|
||||||
Statement statement = this.databaseConnection.createStatement();
|
Statement statement = this.databaseConnection.createStatement();
|
||||||
statement.execute("DELETE FROM griefprevention_claimdata WHERE id=" + claim.id + ";");
|
statement.execute("DELETE FROM griefprevention_claimdata WHERE lessercorner='" + this.locationToString(claim.lesserBoundaryCorner) + "' AND greatercorner = '" + this.locationToString(claim.greaterBoundaryCorner) + "';");
|
||||||
statement.execute("DELETE FROM griefprevention_claimdata WHERE parentid=" + claim.id + ";");
|
if(claim.id != -1)
|
||||||
|
{
|
||||||
|
statement.execute("DELETE FROM griefprevention_claimdata WHERE parentid=" + claim.id + ";");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(SQLException e)
|
catch(SQLException e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user