if comparator not set use global

pull/1919/head
Night_Hunter 10 months ago
parent c6fba95569
commit a904209dae

@ -263,6 +263,7 @@ impl UpdaterBuilder {
app_name: self.app_name,
current_version: self.current_version,
version_comparator: self.version_comparator,
global_version_comparator: self.global_version_comparator,
timeout: self.timeout,
proxy: self.proxy,
endpoints,
@ -295,6 +296,7 @@ pub struct Updater {
app_name: String,
current_version: Version,
version_comparator: Option<Box<dyn Fn(Version, RemoteRelease) -> bool + Send + Sync>>,
global_version_comparator: Option<GlobalVersionComparator>,
timeout: Option<Duration>,
proxy: Option<Url>,
endpoints: Vec<Url>,
@ -405,7 +407,15 @@ impl Updater {
let should_update = match self.version_comparator.as_ref() {
Some(comparator) => comparator(self.current_version.clone(), release.clone()),
None => release.version > self.current_version,
None => {
match self.global_version_comparator.as_ref() {
Some(comparator) => comparator(self.current_version.clone(), release.clone()),
None => {
// default comparator
release.version > self.current_version
}
}
}
};
let update = if should_update {

Loading…
Cancel
Save