From 1fc6b622dbff96967b44bce76cd87a70a4faad40 Mon Sep 17 00:00:00 2001 From: poikilos <7557867+poikilos@users.noreply.github.com> Date: Sun, 21 Feb 2016 00:16:48 -0500 Subject: [PATCH] fix check for change in metadata to decrease writes instead of never writing due to bug in chunkymap-cronjob --- chunkymap-cronjob | 9 +++++---- chunkymap-regen.py | 23 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/chunkymap-cronjob b/chunkymap-cronjob index 1be6e4b..8691a25 100644 --- a/chunkymap-cronjob +++ b/chunkymap-cronjob @@ -2,7 +2,8 @@ # NOTE: only works since all scripts in /etc/cron.*/ or crontab run as root #python /home/owner/minetest/util/chunkymap-regen.py #-1 FOR LESS THAN ONE MINUTE AGO: -MT_PLAYERS_ACTIVE_COUNT=$(find /var/www/html/minetest/chunkymapdata/players -type f -mmin -1 | wc -l) -if[ $MT_PLAYERS_ACTIVE_COUNT -gt 0 ]; then - flock -n /var/run/chunkymap-regen.lockfile -c /home/owner/minetest/util/chunkymap-regen.sh -fi \ No newline at end of file +#lol won't work because if the py doesn't run the players won't be updated +#MT_PLAYERS_ACTIVE_COUNT=$(find /var/www/html/minetest/chunkymapdata/players -type f -mmin -1 | wc -l) +#if[ $MT_PLAYERS_ACTIVE_COUNT -gt 0 ]; then +flock -n /var/run/chunkymap-regen.lockfile -c /home/owner/minetest/util/chunkymap-regen.sh +#fi \ No newline at end of file diff --git a/chunkymap-regen.py b/chunkymap-regen.py index 0412b99..688b55f 100644 --- a/chunkymap-regen.py +++ b/chunkymap-regen.py @@ -316,13 +316,34 @@ if os.path.isfile(mtmn_path) and os.path.isfile(colors_path): chunkx_max += 1 chunkz_max += 1 #end while square outline (1-chunk-thick outline) generated any png files + new_map_dict = {} + new_map_dict["world_name"]=str(world_name) + new_map_dict["chunk_size"]=str(chunk_size) + new_map_dict["pixelspernode"]=str(pixelspernode) + new_map_dict["chunkx_min"]=str(chunkx_min) + new_map_dict["chunkx_max"]=str(chunkx_max) + new_map_dict["chunkz_min"]=str(chunkz_min) + new_map_dict["chunkz_max"]=str(chunkz_max) + new_map_dict["maxheight"]=str(maxheight) + new_map_dict["minheight"]=str(minheight) + new_map_dict["world_path"]=str(world_path) + new_map_dict["chunkymap_data_path"]=str(chunkymap_data_path) + new_map_dict["total_generated_count"]=str(total_generated_count) + is_changed = False + if mapvars is None: + is_changed = True + else: + for this_key in new_map_dict.iterkeys(): + if (this_key not in mapvars.keys()) or (str(mapvars[this_key]) != str(new_map_dict[this_key])): + is_changed = True + break outs = open(yaml_path, 'w') outs.write("world_name:"+str(world_name) + "\n") outs.write("chunk_size:"+str(chunk_size) + "\n") outs.write("pixelspernode:"+str(pixelspernode) + "\n") outs.write("chunkx_min:"+str(chunkx_min) + "\n") - outs.write("chunkz_min:"+str(chunkz_min) + "\n") outs.write("chunkx_max:"+str(chunkx_max) + "\n") + outs.write("chunkz_min:"+str(chunkz_min) + "\n") outs.write("chunkz_max:"+str(chunkz_max) + "\n") #values for command arguments: outs.write("maxheight:"+str(maxheight) + "\n")