From 24da318802f75c2088d4a0d5ae486b4519700a15 Mon Sep 17 00:00:00 2001 From: mpeterv Date: Sun, 3 Apr 2016 21:19:44 +0300 Subject: [PATCH] Add version to manifest Increment when changing manifest format in breaking ways so that upgrading hererocks doesn't result in a crash. --- hererocks.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hererocks.py b/hererocks.py index 2ed185d..44513b5 100755 --- a/hererocks.py +++ b/hererocks.py @@ -990,17 +990,26 @@ class LuaRocks(Program): def get_manifest_name(): return os.path.join(opts.location, "hererocks.manifest") +manifest_version = 1 + def get_installed_identifiers(): if not os.path.exists(get_manifest_name()): return {} with open(get_manifest_name()) as manifest_h: try: - return json.load(manifest_h) + identifiers = json.load(manifest_h) except ValueError: return {} + if identifiers.get("version") == manifest_version: + return identifiers + else: + return {} + def save_installed_identifiers(all_identifiers): + all_identifiers["version"] = manifest_version + with open(get_manifest_name(), "w") as manifest_h: json.dump(all_identifiers, manifest_h)