Additional safety check to make sure EntityCollection.saveToDisc() can't run multiple iterations simultaneously; this might have been the cause of some reports of corrupted data

This commit is contained in:
Brettflan 2013-04-18 03:24:23 -05:00
parent f7d57efe0b
commit 63837691ce
2 changed files with 9 additions and 2 deletions

Binary file not shown.

View File

@ -173,8 +173,14 @@ public abstract class EntityCollection<E extends Entity>
// DISC // DISC
// -------------------------------------------- // // -------------------------------------------- //
// we don't want to let saveToDisc() run multiple iterations simultaneously
private boolean saveIsRunning = false;
public boolean saveToDisc() public boolean saveToDisc()
{ {
if (saveIsRunning) return true;
saveIsRunning = true;
Map<String, E> entitiesThatShouldBeSaved = new HashMap<String, E>(); Map<String, E> entitiesThatShouldBeSaved = new HashMap<String, E>();
for (E entity : this.entities) for (E entity : this.entities)
{ {
@ -184,6 +190,7 @@ public abstract class EntityCollection<E extends Entity>
} }
} }
saveIsRunning = false;
return this.saveCore(entitiesThatShouldBeSaved); return this.saveCore(entitiesThatShouldBeSaved);
} }