Skip to content

Commit

Permalink
Simple check for removing current directory resolving ESCOMP#2412 in …
Browse files Browse the repository at this point in the history
…a simple way
  • Loading branch information
ekluzek committed Mar 13, 2024
1 parent 20e3e7a commit 605addb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/ctsm/site_and_regional/neon_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# pylint: disable=wrong-import-position, import-error, unused-import, wrong-import-order
from ctsm import add_cime_to_path
from ctsm.path_utils import path_to_ctsm_root
from ctsm.utils import abort

from CIME import build
from CIME.case import Case
Expand Down Expand Up @@ -75,6 +76,9 @@ def build_base_case(

if overwrite and os.path.isdir(case_path):
print("Removing the existing case at: {}".format(case_path))
if os.getcwd() == case_path:
abort("Trying to remove the directory tree that we are in")

shutil.rmtree(case_path)

with Case(case_path, read_only=False) as case:
Expand Down Expand Up @@ -211,6 +215,8 @@ def run_case(
if os.path.isdir(case_root):
if overwrite:
print("---- removing the existing case -------")
if os.getcwd() == case_root:
abort("Trying to remove the directory tree that we are in")
shutil.rmtree(case_root)
elif rerun:
with Case(case_root, read_only=False) as case:
Expand Down

0 comments on commit 605addb

Please sign in to comment.