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
Added fn to get latest chrome revision(requires fetch feature) #374
Added fn to get latest chrome revision(requires fetch feature) #374
Conversation
Hey @initprism thanks for the PR but can you explain the use of this method to fetch latest chrome revision? |
The let revision = headless_chrome::browser::latest_chrome_revision()?;
let fetcher_options = headless_chrome::FetcherOptions::default()
.with_revision(revision);
let launch_options = headless_chrome::LaunchOptionsBuilder::default()
.fetcher_options(fetcher_options)
.build()?;
let browser = Browser::new(launch_options)?; IMO, I don't think it's correct to always install the latest chrome revision when enable the fetch feature. |
I think this is really useful @initprism, maybe it can be re-designed in a way that extends the current .with_revision("some-version") function, rather than adding a new function, e.g. we can define a enum Version {
Specific(S), // S: Into<String>
Latest
}
.with_revision(Version::Specific("634997"))
or
.with_revision(Version::Latest) |
Makes sense thanks for the explanation ! |
src/browser/mod.rs
Outdated
if cfg!(target_os = "linux") { | ||
url = format!("{}/Linux_x64/LAST_CHANGE", url); | ||
} else if cfg!(all(target_os = "macos", target_arch = "aarch64")) { | ||
url = format!("{}/Mac_Arm/LAST_CHANGE", url); | ||
} else if cfg!(all(target_os = "macos", not(target_arch = "aarch64"))) { | ||
url = format!("{}/Mac/LAST_CHANGE", url); | ||
} else if cfg!(windows) { | ||
url = format!("{}/Win_x64/LAST_CHANGE", url); | ||
} else { | ||
// This code will panic on unsupported platforms. | ||
#[allow(unreachable_code)] | ||
{ | ||
unimplemented!("This platform is not supported") | ||
} | ||
} |
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.
maybe it would be better to refactor this into a match statement ?
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.
Refactoring to match statement looks good. And reflecting the definition suggested by @masc-it looks good.
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.
Refactoring to match statement looks good. And reflecting the definition suggested by @masc-it looks good.
Cool i will wait for you to add these changes. Then we can merge this PR
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.
I'm sorry I closed this PR by mistake. (;_;)
please check #380
726a2e8
to
ce087b2
Compare
No description provided.