-
-
Notifications
You must be signed in to change notification settings - Fork 93
Downloader updated to skip unchanged files #3182
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -212,15 +212,42 @@ def predbat_update_download(version): | |||||||||
| print("Error: Failed to get file list from GitHub") | ||||||||||
| return None | ||||||||||
|
|
||||||||||
| # Download all files | ||||||||||
| # Download all files (skip if local file has matching SHA) | ||||||||||
| downloaded_files = [] | ||||||||||
| skipped_files = [] | ||||||||||
| for file_info in file_list: | ||||||||||
| filename = file_info["name"] | ||||||||||
| if not download_predbat_file_from_github(tag, filename, os.path.join(this_path, filename + "." + tag)): | ||||||||||
| print("Error: Failed to download {}".format(filename)) | ||||||||||
| return None | ||||||||||
| expected_sha = file_info.get("sha") | ||||||||||
| local_filepath = os.path.join(this_path, filename) | ||||||||||
| download_filepath = os.path.join(this_path, filename + "." + tag) | ||||||||||
|
|
||||||||||
| # Check if local file exists and has matching SHA | ||||||||||
| skip_download = False | ||||||||||
| if expected_sha and os.path.exists(local_filepath): | ||||||||||
| local_sha = compute_file_sha1(local_filepath) | ||||||||||
| if local_sha == expected_sha: | ||||||||||
| print("Skipping {}: local file matches remote SHA ({})".format(filename, expected_sha[:8])) | ||||||||||
| # Copy local file to download location so move operation works | ||||||||||
| try: | ||||||||||
| with open(local_filepath, "rb") as src: | ||||||||||
| with open(download_filepath, "wb") as dst: | ||||||||||
|
Comment on lines
+232
to
+233
|
||||||||||
| with open(local_filepath, "rb") as src: | |
| with open(download_filepath, "wb") as dst: | |
| with open(local_filepath, "r") as src: | |
| with open(download_filepath, "w") as dst: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name
downloaded_filesis misleading because it includes both downloaded files and skipped files. Files that are skipped (due to matching SHA) are added to this list at line 246, even though they weren't actually downloaded from GitHub. Consider renaming this toprocessed_filesorstaged_filesto better reflect that it includes all files prepared for installation, regardless of whether they were downloaded or copied from local.