From 3d919dbfc4b269077b10dd300dc9036c7333977d Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Wed, 23 Mar 2016 12:58:16 -0700 Subject: [PATCH] Don't overwrite worlds. This would usually result in an unreadable error crash, so this is much nicer. --- mcimport.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mcimport.py b/mcimport.py index 52cec87..60b89e3 100755 --- a/mcimport.py +++ b/mcimport.py @@ -10,12 +10,16 @@ if (sys.version_info < (3, 0)): exit(1) if not os.path.exists(sys.argv[1]): - print("the minecraft world path does not exist.") + print("The provided minecraft world path does not exist.") exit(1) if not os.path.exists(sys.argv[2]): os.makedirs(sys.argv[2]) +if os.path.exists(sys.argv[2] + "map.sqlite"): + print("A minetest world already exists - refusing to overwrite it.") + exit(1) + if not os.path.exists(sys.argv[2] + "/world.mt"): wo = open(sys.argv[2] + "/world.mt", "w") wo.write("backend = sqlite3\n")