Conversation
Summary of ChangesHello @hczphn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request updates the infrastructure for fetching external data files by changing their download source from GitHub releases to a dedicated R2 storage service. This change centralizes the download URLs and refines the download utility to be more efficient and robust. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request changes the download URL for test data and refactors the download logic. The new implementation consolidates two download functions into one, but this changes the error handling for optional files, which will now cause a panic on failure. I've also suggested an improvement to make the command execution safer by avoiding bash -c. Overall, the changes are straightforward but the change in error handling should be reviewed to ensure it's intended.
| fn download_and_store(url_path: &str, file: &str) { | ||
| // Skip download if file already exists | ||
| if std::path::Path::new(file).exists() { | ||
| println!("File already exists, skipping download: {}", file); | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| fn download_and_store_required(url: &str, file: &str) { | ||
| let url = format!("{}{}", URL_PREFIX, url_path); | ||
| let download = Command::new("bash") | ||
| .arg("-c") | ||
| .arg(format!("wget -L {url} -O {file}")) | ||
| .arg(format!("wget {} -O {}", url, file)) | ||
| .output() | ||
| .expect("Failed to execute wget"); | ||
| .expect("Failed to download circuit"); | ||
|
|
||
| assert!(download.status.success(), "Required file download failed: {url}"); | ||
| assert!(download.status.success(), "Circuit download failure: {}", url) | ||
| } |
There was a problem hiding this comment.
The new download_and_store function consolidates the logic of the previous download_and_store and download_and_store_required functions. However, this new implementation will panic on any download failure, which was previously the behavior only for required files. Files that were considered optional (like Goldilocks and BabyBear circuits) will now cause the setup to fail if they cannot be downloaded. If all files are now guaranteed to be available at the new URL, this change is acceptable. Otherwise, you might want to consider re-introducing a non-panicking download variant for optional files.
| let download = Command::new("bash") | ||
| .arg("-c") | ||
| .arg(format!("wget -L {url} -O {file}")) | ||
| .arg(format!("wget {} -O {}", url, file)) |
There was a problem hiding this comment.
Using bash -c with a formatted string to execute commands can be risky as it can lead to shell injection vulnerabilities if the arguments are not properly sanitized. Although the url and file variables seem to be from controlled sources in this case, it's a best practice to avoid invoking a shell when possible. Passing arguments directly to Command::new("wget") is safer and more robust.
| let download = Command::new("bash") | |
| .arg("-c") | |
| .arg(format!("wget -L {url} -O {file}")) | |
| .arg(format!("wget {} -O {}", url, file)) | |
| let download = Command::new("wget").arg(&url).arg("-O").arg(file) |
No description provided.