Skip to content

Commit 2e34507

Browse files
committed
Use FileReplacer to manage the uuid cache file
1 parent 270741e commit 2e34507

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

overviewer_core/aux_files/genPOI.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from overviewer_core import logger
3434
from overviewer_core import nbt
3535
from overviewer_core import configParser, world
36+
from overviewer_core.files import FileReplacer
3637

3738
UUID_LOOKUP_URL = 'https://sessionserver.mojang.com/session/minecraft/profile/'
3839

@@ -233,13 +234,11 @@ def load_cache(cls, outputdir):
233234
@classmethod
234235
def save_cache(cls, outputdir):
235236
cache_file = os.path.join(outputdir, "uuidcache.dat")
236-
try:
237-
gz = gzip.GzipFile(cache_file + ".tmp", "wb")
237+
238+
with FileReplacer(cache_file) as cache_file_name:
239+
gz = gzip.GzipFile(cache_file_name, "wb")
238240
json.dump(cls.uuid_cache, gz)
239-
os.rename(cache_file + ".tmp", cache_file)
240241
logging.info("Wrote UUID cache with %d entries", len(cls.uuid_cache.keys()))
241-
except (IOError, OSError):
242-
logging.warning("Failed to save UUID cache!")
243242

244243
def __getitem__(self, item):
245244
if item == "EntityId":

0 commit comments

Comments
 (0)