From a06a7f1f057121d5be068c78b437d0aed095aff1 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 24 Aug 2020 22:22:47 +0200 Subject: [PATCH] Handle already-present directories for git assets --- spacy/cli/project/assets.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spacy/cli/project/assets.py b/spacy/cli/project/assets.py index 3905c0976..6ccc8523d 100644 --- a/spacy/cli/project/assets.py +++ b/spacy/cli/project/assets.py @@ -48,7 +48,13 @@ def project_assets(project_dir: Path) -> None: dest = Path(asset["dest"]) checksum = asset.get("checksum") if "git" in asset: - print(dest) + if dest.exists(): + # If there's already a file, check for checksum + if checksum and checksum == get_checksum(dest_path): + msg.good(f"Skipping download with matching checksum: {dest}") + continue + else: + shutil.rmtree(dest) git_sparse_checkout(asset["git"]["repo"], asset["git"]["path"], dest) else: url = asset.get("url")