Skip to content

Commit c29e5bb

Browse files
committed
fix a bug introduced in the previous 2-3 commits
1 parent 68e3b27 commit c29e5bb

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

ctf/utils.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import jinja2
99
import yaml
10-
1110
from ctf import ENV
1211
from ctf.logger import LOG
1312

@@ -225,15 +224,12 @@ def find_ctf_root_directory() -> str:
225224
if "CTF_ROOT_DIR" in ENV
226225
else os.path.join(os.getcwd(), ".")
227226
)
227+
if not is_ctf_dir(path=path):
228+
while path != (path := os.path.dirname(p=path)):
229+
ctf_dir = is_ctf_dir(path)
228230

229-
while path != (path := os.path.dirname(p=path)):
230-
dir = os.listdir(path=path)
231-
232-
if ".deploy" not in dir:
233-
continue
234-
if "challenges" not in dir:
235-
continue
236-
break
231+
if ctf_dir:
232+
break
237233

238234
if path == "/":
239235
LOG.critical(
@@ -246,6 +242,16 @@ def find_ctf_root_directory() -> str:
246242
return (__CTF_ROOT_DIRECTORY := path)
247243

248244

245+
def is_ctf_dir(path):
246+
ctf_dir = True
247+
dir = os.listdir(path=path)
248+
if ".deploy" not in dir:
249+
ctf_dir = False
250+
if "challenges" not in dir:
251+
ctf_dir = False
252+
return ctf_dir
253+
254+
249255
def terraform_binary() -> str:
250256
path = shutil.which(cmd="tofu")
251257
if not path:

0 commit comments

Comments
 (0)