From c438f81e2806537a2ccebd8d950840b20d8b072a Mon Sep 17 00:00:00 2001 From: "Christopher J. Wright" Date: Fri, 13 Nov 2020 16:18:06 -0500 Subject: [PATCH 1/3] only remove files that exist --- conda_smithy/configure_feedstock.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py index dd8eb1372..9f04c8d35 100644 --- a/conda_smithy/configure_feedstock.py +++ b/conda_smithy/configure_feedstock.py @@ -1608,7 +1608,9 @@ def _load_forge_config(forge_dir, exclusive_config_file): for old_file in old_files: if old_file.replace(os.sep, "/") in config["skip_render"]: continue - remove_file_or_dir(os.path.join(forge_dir, old_file)) + file_with_path = os.path.join(forge_dir, old_file) + if os.path.exists(file_with_path): + remove_file_or_dir(file_with_path) # Set some more azure defaults config["azure"].setdefault("user_or_org", config["github"]["user_or_org"]) From 5d82e402fdd156d6033bb26c5f5b80e38d8f88d4 Mon Sep 17 00:00:00 2001 From: "Christopher J. Wright" Date: Fri, 13 Nov 2020 16:20:06 -0500 Subject: [PATCH 2/3] news --- news/bad_remove.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 news/bad_remove.rst diff --git a/news/bad_remove.rst b/news/bad_remove.rst new file mode 100644 index 000000000..8e5af7f61 --- /dev/null +++ b/news/bad_remove.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* Don't try to remove files that don't exist + +**Security:** + +* From cf1f5c777f3e14abb3103e42676eb76837a4f612 Mon Sep 17 00:00:00 2001 From: "Christopher J. Wright" Date: Fri, 13 Nov 2020 16:47:28 -0500 Subject: [PATCH 3/3] put the fix in the wrong place --- conda_smithy/configure_feedstock.py | 3 +-- conda_smithy/feedstock_io.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py index 9f04c8d35..24cb444de 100644 --- a/conda_smithy/configure_feedstock.py +++ b/conda_smithy/configure_feedstock.py @@ -1609,8 +1609,7 @@ def _load_forge_config(forge_dir, exclusive_config_file): if old_file.replace(os.sep, "/") in config["skip_render"]: continue file_with_path = os.path.join(forge_dir, old_file) - if os.path.exists(file_with_path): - remove_file_or_dir(file_with_path) + remove_file_or_dir(file_with_path) # Set some more azure defaults config["azure"].setdefault("user_or_org", config["github"]["user_or_org"]) diff --git a/conda_smithy/feedstock_io.py b/conda_smithy/feedstock_io.py index 6878850af..e55851e4d 100644 --- a/conda_smithy/feedstock_io.py +++ b/conda_smithy/feedstock_io.py @@ -63,7 +63,7 @@ def remove_file_or_dir(filename): return remove_file(filename) repo = get_repo(filename) - if repo: + if repo and filename in repo.head.commit.tree: repo.index.remove([filename], r=True) shutil.rmtree(filename)