Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check registry file hash before downloading #93

Merged
merged 15 commits into from
Apr 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/lephare/data_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,7 @@ def _check_registry_is_latest_version(remote_registry_url, local_registry_file):
remote_hash_response = requests.get(remote_hash_url, timeout=60)
remote_hash_response.raise_for_status() # Raise exceptions for non-200 status codes

if remote_hash_response.text.strip() == local_registry_hash:
print(f"Local registry file is up to date: {local_registry_file}")
return True
else:
print(f"Local registry file is not up to date: {local_registry_file}")
return False
return remote_hash_response.text.strip() == local_registry_hash
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice



def download_registry_from_github(url="", outfile=""):
Expand Down Expand Up @@ -121,6 +116,7 @@ def download_registry_from_github(url="", outfile=""):

# If local registry hash matches remote hash, our registry is already up-to-date:
if os.path.isfile(outfile) and _check_registry_is_latest_version(url, outfile):
print(f"Local registry file is up to date: {local_registry_file}")
return

# Download the registry file
Expand Down
Loading