Skip to content

Conversation

@springfall2008
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings January 4, 2026 20:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes the Predbat update/download process by skipping downloads of files that haven't changed, comparing local file SHA1 hashes against remote GitHub file hashes. When a match is found, the local file is copied to the staging location instead of being re-downloaded from GitHub.

Key Changes

  • SHA-based download optimization that skips unchanged files by comparing local and remote file hashes
  • Two comprehensive test cases validating skip behavior for both full-match and mixed scenarios
  • Enhanced user feedback showing which files were skipped during updates

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
apps/predbat/download.py Implements SHA comparison logic to skip downloading unchanged files, copying local versions to staging instead
apps/predbat/tests/test_download.py Adds two test cases: one verifying skip behavior when SHAs match, another testing mixed scenarios with both matching and non-matching files

Comment on lines +232 to +233
with open(local_filepath, "rb") as src:
with open(download_filepath, "wb") as dst:
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

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

File mode inconsistency detected. The copy operation uses binary mode ("rb"/"wb") while download_predbat_file_from_github uses text mode ("w"). This inconsistency could cause different line endings on Windows (CRLF vs LF) between downloaded files and copied files, potentially leading to SHA mismatches on subsequent checks. For consistency, either both should use binary mode, or both should use text mode. Recommend using binary mode for both since the SHA computation in compute_file_sha1 operates on binary data.

Suggested change
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:

Copilot uses AI. Check for mistakes.

# Download all files
# Download all files (skip if local file has matching SHA)
downloaded_files = []
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

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

The variable name downloaded_files is 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 to processed_files or staged_files to better reflect that it includes all files prepared for installation, regardless of whether they were downloaded or copied from local.

Copilot uses AI. Check for mistakes.
@springfall2008 springfall2008 merged commit df95683 into main Jan 4, 2026
1 check passed
@springfall2008 springfall2008 deleted the download branch January 4, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants