From b3abb072c8c1dc7104de82c24bb476cba094807d Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Mon, 13 Dec 2010 22:16:35 +1000 Subject: [PATCH] Use chunk.check_cache --- chunk.py | 8 ++++++-- world.py | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/chunk.py b/chunk.py index f6042bf..181553e 100644 --- a/chunk.py +++ b/chunk.py @@ -131,8 +131,12 @@ def find_oldimage(chunkfile, cached, cave): return oldimg, oldimg_path def check_cache(chunkfile, oldimg): - if os.path.getmtime(chunkfile) <= os.path.getmtime(oldimg[1]): - return self.oldimg_path + try: + if oldimg[1] and os.path.getmtime(chunkfile) <= os.path.getmtime(oldimg[1]): + return True + return False + except OSError: + return False def render_and_save(chunkfile, cachedir, worldobj, oldimg, cave=False, queue=None): """Used as the entry point for the multiprocessing workers (since processes diff --git a/world.py b/world.py index be90a73..effc46a 100644 --- a/world.py +++ b/world.py @@ -301,7 +301,7 @@ class WorldRenderer(object): continue oldimg = chunk.find_oldimage(chunkfile, cached, self.caves) - if oldimg[1] and (os.path.getmtime(chunkfile) <= os.path.getmtime(oldimg[1])): + if chunk.check_cache(chunkfile, oldimg[1]): result = oldimg[1] else: result = chunk.render_and_save(chunkfile, self.cachedir, self, oldimg, queue=q) @@ -331,7 +331,7 @@ class WorldRenderer(object): continue oldimg = chunk.find_oldimage(chunkfile, cached, self.caves) - if oldimg[1] and (os.path.getmtime(chunkfile) <= os.path.getmtime(oldimg[1])): + if chunk.check_cache(chunkfile, oldimg[1]): result = FakeAsyncResult(oldimg[1]) else: result = pool.apply_async(chunk.render_and_save,