From 817e4dc3380ba66e93465cf28262f8f96eb07a1f Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Sat, 15 Feb 2025 01:08:52 +0200 Subject: [PATCH] `version_up_current_workfile`: Raise error if parent folder of the workfile doesn't exist. --- client/ayon_core/pipeline/context_tools.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index beb62755f5..a2732d2c55 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -623,4 +623,12 @@ def version_up_current_workfile(): new_workfile_path = last_workfile_path if os.path.exists(new_workfile_path): new_workfile_path = version_up(new_workfile_path) + + # Raise an error if the parent folder doesn't exist as `host.save_workfile` + # is not supposed/able to create missing folders. + parent_folder = os.path.dirname(new_workfile_path) + if not os.path.exists(parent_folder): + raise AssertionError( + f"Folder {parent_folder} does not exist yet.") + host.save_workfile(new_workfile_path)