Catch struct errors when checking session lock.

This commit is contained in:
David Vierra 2012-11-30 16:35:39 -10:00
parent e0f1ca1799
commit 4d1d96863b

View File

@ -1091,7 +1091,10 @@ class MCInfdevOldLevel(ChunkedLevelMixin, EntityLevel):
def checkSessionLock(self):
lockfile = self.worldFolder.getFilePath("session.lock")
(lock, ) = struct.unpack(">q", file(lockfile, "rb").read())
try:
(lock, ) = struct.unpack(">q", file(lockfile, "rb").read())
except struct.error:
lock = -1
if lock != self.initTime:
raise SessionLockLost, "Session lock lost. This world is being accessed from another location."