From 62f5521e534bbdc68f406c303d6b1490b5e814d3 Mon Sep 17 00:00:00 2001 From: Darragh Van Tichelen Date: Wed, 4 Dec 2024 17:50:55 +0100 Subject: [PATCH] bug(Assets): Fix new assets not always saving due to missing folders --- server/src/api/socket/asset_manager/core.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/src/api/socket/asset_manager/core.py b/server/src/api/socket/asset_manager/core.py index bd3ed5218..542e2b652 100644 --- a/server/src/api/socket/asset_manager/core.py +++ b/server/src/api/socket/asset_manager/core.py @@ -267,10 +267,11 @@ async def handle_regular_file(upload_data: ApiAssetUpload, data: bytes, sid: str sh = hashlib.sha1(data) hashname = sh.hexdigest() - full_hash_path = get_asset_hash_subpath(hashname) + full_hash_path = ASSETS_DIR / get_asset_hash_subpath(hashname) - if not (ASSETS_DIR / full_hash_path).exists(): - with open(ASSETS_DIR / full_hash_path, "wb") as f: + if not full_hash_path.exists(): + full_hash_path.parent.mkdir(parents=True, exist_ok=True) + with open(full_hash_path, "wb") as f: f.write(data) user = asset_state.get_user(sid)