Use chunk.check_cache
This commit is contained in:
8
chunk.py
8
chunk.py
@@ -131,8 +131,12 @@ def find_oldimage(chunkfile, cached, cave):
|
|||||||
return oldimg, oldimg_path
|
return oldimg, oldimg_path
|
||||||
|
|
||||||
def check_cache(chunkfile, oldimg):
|
def check_cache(chunkfile, oldimg):
|
||||||
if os.path.getmtime(chunkfile) <= os.path.getmtime(oldimg[1]):
|
try:
|
||||||
return self.oldimg_path
|
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):
|
def render_and_save(chunkfile, cachedir, worldobj, oldimg, cave=False, queue=None):
|
||||||
"""Used as the entry point for the multiprocessing workers (since processes
|
"""Used as the entry point for the multiprocessing workers (since processes
|
||||||
|
|||||||
4
world.py
4
world.py
@@ -301,7 +301,7 @@ class WorldRenderer(object):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
oldimg = chunk.find_oldimage(chunkfile, cached, self.caves)
|
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]
|
result = oldimg[1]
|
||||||
else:
|
else:
|
||||||
result = chunk.render_and_save(chunkfile, self.cachedir, self, oldimg, queue=q)
|
result = chunk.render_and_save(chunkfile, self.cachedir, self, oldimg, queue=q)
|
||||||
@@ -331,7 +331,7 @@ class WorldRenderer(object):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
oldimg = chunk.find_oldimage(chunkfile, cached, self.caves)
|
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])
|
result = FakeAsyncResult(oldimg[1])
|
||||||
else:
|
else:
|
||||||
result = pool.apply_async(chunk.render_and_save,
|
result = pool.apply_async(chunk.render_and_save,
|
||||||
|
|||||||
Reference in New Issue
Block a user