mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
72b483f0c5
commit
897eb54e98
4 changed files with 11 additions and 16 deletions
|
|
@ -100,14 +100,6 @@ impl<'a> Body<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn as_hey(&self) -> Option<&BodyHey> {
|
|
||||||
match self {
|
|
||||||
Self::Hey(b) => Some(b),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn with_receiver(self, receiver: u64) -> Payload<'a> {
|
pub fn with_receiver(self, receiver: u64) -> Payload<'a> {
|
||||||
Payload::new(self).with_receiver(receiver)
|
Payload::new(self).with_receiver(receiver)
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,6 @@ impl BodyHey {
|
||||||
pub fn owned(peers: HashMap<u64, Peer>) -> Body<'static> {
|
pub fn owned(peers: HashMap<u64, Peer>) -> Body<'static> {
|
||||||
Self { peers, version: BodyHi::version() }.into()
|
Self { peers, version: BodyHi::version() }.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn match_version(&self) -> bool { self.version == BodyHi::version() }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<BodyHey> for Body<'_> {
|
impl From<BodyHey> for Body<'_> {
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,7 @@ impl<'a> BodyHi<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(super) fn version() -> String {
|
pub fn version() -> String { format!("{} {}", env!("CARGO_PKG_VERSION"), env!("VERGEN_GIT_SHA")) }
|
||||||
format!("{} {}", env!("CARGO_PKG_VERSION"), env!("VERGEN_GIT_SHA"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<BodyHi<'a>> for Body<'a> {
|
impl<'a> From<BodyHi<'a>> for Body<'a> {
|
||||||
|
|
|
||||||
|
|
@ -77,11 +77,12 @@ impl Client {
|
||||||
writer.flush().await?;
|
writer.flush().await?;
|
||||||
drop(writer);
|
drop(writer);
|
||||||
|
|
||||||
|
let mut version = None;
|
||||||
while let Ok(Some(line)) = lines.next_line().await {
|
while let Ok(Some(line)) = lines.next_line().await {
|
||||||
match line.split(',').next() {
|
match line.split(',').next() {
|
||||||
Some("hey") => {
|
Some("hey") => {
|
||||||
if !Payload::from_str(&line)?.body.as_hey().is_some_and(|b| b.match_version()) {
|
if let Ok(Body::Hey(hey)) = Payload::from_str(&line).map(|p| p.body) {
|
||||||
bail!("Server version mismatch - `yazi` and `ya` must have the same version")
|
version = Some(hey.version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some("bye") => break,
|
Some("bye") => break,
|
||||||
|
|
@ -89,6 +90,13 @@ impl Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if version != Some(BodyHi::version()) {
|
||||||
|
bail!(
|
||||||
|
"Incompatible version - Yazi {} <==> Ya {}",
|
||||||
|
version.as_deref().unwrap_or("Unknown"),
|
||||||
|
BodyHi::version()
|
||||||
|
);
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue