mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 17:36:30 +03:00
Check for assets with size of 0 bytes (#10026)
* Check for assets with size of 0 bytes * Update spacy/cli/project/assets.py Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com> Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
This commit is contained in:
parent
5ba4171b19
commit
057b8c64c0
|
@ -1,6 +1,7 @@
|
||||||
from typing import Any, Dict, Optional
|
from typing import Any, Dict, Optional
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from wasabi import msg
|
from wasabi import msg
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import requests
|
import requests
|
||||||
|
@ -129,10 +130,17 @@ def fetch_asset(
|
||||||
the asset failed.
|
the asset failed.
|
||||||
"""
|
"""
|
||||||
dest_path = (project_path / dest).resolve()
|
dest_path = (project_path / dest).resolve()
|
||||||
if dest_path.exists() and checksum:
|
if dest_path.exists():
|
||||||
# If there's already a file, check for checksum
|
# If there's already a file, check for checksum
|
||||||
if checksum == get_checksum(dest_path):
|
if checksum:
|
||||||
msg.good(f"Skipping download with matching checksum: {dest}")
|
if checksum == get_checksum(dest_path):
|
||||||
|
msg.good(f"Skipping download with matching checksum: {dest}")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
# If there's not a checksum, make sure the file is a possibly valid size
|
||||||
|
if os.path.getsize(dest_path) == 0:
|
||||||
|
msg.warn(f"Asset exists but with size of 0 bytes, deleting: {dest}")
|
||||||
|
os.remove(dest_path)
|
||||||
# We might as well support the user here and create parent directories in
|
# We might as well support the user here and create parent directories in
|
||||||
# case the asset dir isn't listed as a dir to create in the project.yml
|
# case the asset dir isn't listed as a dir to create in the project.yml
|
||||||
if not dest_path.parent.exists():
|
if not dest_path.parent.exists():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user