From efc9593a2cddc4060d9c1482d5f21558df0774ef Mon Sep 17 00:00:00 2001 From: Yan Date: Mon, 18 Nov 2024 03:12:54 -0700 Subject: [PATCH] clone dojo if directory is not found (e.g., database restores) --- dojo_plugin/utils/dojo.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dojo_plugin/utils/dojo.py b/dojo_plugin/utils/dojo.py index 6be73b08..81987cab 100644 --- a/dojo_plugin/utils/dojo.py +++ b/dojo_plugin/utils/dojo.py @@ -445,9 +445,13 @@ def dojo_git_command(dojo, *args): def dojo_update(dojo): - dojo_git_command(dojo, "fetch", "--depth=1", "origin") - dojo_git_command(dojo, "reset", "--hard", "origin") - dojo_git_command(dojo, "submodule", "update", "--init", "--recursive") + if dojo.path.exists(): + dojo_git_command(dojo, "fetch", "--depth=1", "origin") + dojo_git_command(dojo, "reset", "--hard", "origin") + dojo_git_command(dojo, "submodule", "update", "--init", "--recursive") + else: + tmpdir = dojo_clone(dojo.repository, dojo.private_key) + os.rename(tmpdir.name, str(dojo.path)) return dojo_from_dir(dojo.path, dojo=dojo)