refact is_peer_version_ge, and fix version comparation > to >=

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-04-07 14:46:18 +08:00
parent eb0acc33e2
commit d6c8fb2b28
3 changed files with 25 additions and 19 deletions

View File

@@ -818,3 +818,21 @@ pub async fn get_key(sync: bool) -> String {
}
key
}
pub fn is_peer_version_ge(v: &str) -> bool {
#[cfg(not(any(feature = "flutter", feature = "cli")))]
if let Some(session) = crate::ui::CUR_SESSION.lock().unwrap().as_ref() {
return session.get_peer_version() >= hbb_common::get_version_number(v);
}
#[cfg(feature = "flutter")]
if let Some(session) = crate::flutter::SESSIONS
.read()
.unwrap()
.get(&*crate::flutter::CUR_SESSION_ID.read().unwrap())
{
return session.get_peer_version() >= hbb_common::get_version_number(v);
}
false
}