Core: Fix get_unique_identifier failing on missing cache folder (#5322)
This commit is contained in:
7
Utils.py
7
Utils.py
@@ -414,11 +414,11 @@ def get_adjuster_settings(game_name: str) -> Namespace:
|
|||||||
@cache_argsless
|
@cache_argsless
|
||||||
def get_unique_identifier():
|
def get_unique_identifier():
|
||||||
common_path = cache_path("common.json")
|
common_path = cache_path("common.json")
|
||||||
if os.path.exists(common_path):
|
try:
|
||||||
with open(common_path) as f:
|
with open(common_path) as f:
|
||||||
common_file = json.load(f)
|
common_file = json.load(f)
|
||||||
uuid = common_file.get("uuid", None)
|
uuid = common_file.get("uuid", None)
|
||||||
else:
|
except FileNotFoundError:
|
||||||
common_file = {}
|
common_file = {}
|
||||||
uuid = None
|
uuid = None
|
||||||
|
|
||||||
@@ -428,6 +428,9 @@ def get_unique_identifier():
|
|||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
uuid = str(uuid4())
|
uuid = str(uuid4())
|
||||||
common_file["uuid"] = uuid
|
common_file["uuid"] = uuid
|
||||||
|
|
||||||
|
cache_folder = os.path.dirname(common_path)
|
||||||
|
os.makedirs(cache_folder, exist_ok=True)
|
||||||
with open(common_path, "w") as f:
|
with open(common_path, "w") as f:
|
||||||
json.dump(common_file, f, separators=(",", ":"))
|
json.dump(common_file, f, separators=(",", ":"))
|
||||||
return uuid
|
return uuid
|
||||||
|
|||||||
Reference in New Issue
Block a user