Fixed: Session lock is checked before all chunk writes.

This commit is contained in:
David Vierra 2012-11-30 15:47:07 -10:00
parent 761c742bf8
commit e0f1ca1799

View File

@ -1166,7 +1166,11 @@ class MCInfdevOldLevel(ChunkedLevelMixin, EntityLevel):
Unload all chunks and close all open filehandles. Discard any unsaved data. Unload all chunks and close all open filehandles. Discard any unsaved data.
""" """
self.unload() self.unload()
shutil.rmtree(self.unsavedWorkFolder.filename, True) try:
self.checkSessionLock()
shutil.rmtree(self.unsavedWorkFolder.filename, True)
except SessionLockLost:
pass
# --- Resource limits --- # --- Resource limits ---
@ -1356,6 +1360,7 @@ class MCInfdevOldLevel(ChunkedLevelMixin, EntityLevel):
Copy a chunk from world into the same chunk position in self. Copy a chunk from world into the same chunk position in self.
""" """
assert isinstance(world, MCInfdevOldLevel) assert isinstance(world, MCInfdevOldLevel)
self.checkSessionLock()
destChunk = self._loadedChunks.get((cx, cz)) destChunk = self._loadedChunks.get((cx, cz))
sourceChunk = world._loadedChunks.get((cx, cz)) sourceChunk = world._loadedChunks.get((cx, cz))
@ -1422,6 +1427,7 @@ class MCInfdevOldLevel(ChunkedLevelMixin, EntityLevel):
return chunkData return chunkData
def _storeLoadedChunkData(self, chunkData): def _storeLoadedChunkData(self, chunkData):
self.checkSessionLock()
if len(self._loadedChunkData) > self.loadedChunkLimit: if len(self._loadedChunkData) > self.loadedChunkLimit:
# Try to find a chunk to unload. The chunk must not be in _loadedChunks, which contains only chunks that # Try to find a chunk to unload. The chunk must not be in _loadedChunks, which contains only chunks that
# are in use by another object. If the chunk is dirty, save it to the temporary folder. # are in use by another object. If the chunk is dirty, save it to the temporary folder.
@ -1746,6 +1752,7 @@ class MCInfdevOldLevel(ChunkedLevelMixin, EntityLevel):
playerTag['Rotation'] = nbt.TAG_List([nbt.TAG_Float(0), nbt.TAG_Float(0)]) playerTag['Rotation'] = nbt.TAG_List([nbt.TAG_Float(0), nbt.TAG_Float(0)])
if playerName != "Player": if playerName != "Player":
self.checkSessionLock()
playerTag.save(self.getPlayerPath(playerName)) playerTag.save(self.getPlayerPath(playerName))