Skip to content

Commit

Permalink
Fixed parsing version for rsync
Browse files Browse the repository at this point in the history
The case where the server returns additional information along with the version
  • Loading branch information
Volkalex28 committed Sep 18, 2023
1 parent d59a689 commit 4a0b557
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions crates/arrsync/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,11 @@ impl RsyncClient {
hello
);
let ver = hello[rsyncd.len()..(hello.len() - 1)]
.split('.')
.map(str::parse)
.collect::<Result<Vec<u64>, _>>()
.context(format!("Parsing server version from {}", hello))?;
.split(' ')
.next()
.map(|version| version.split('.').map(str::parse).collect::<Result<Vec<u64>, _>>())
.ok_or(anyhow::anyhow!(format!("Version nor present")))
.context(format!("Parsing server version from {}", hello))??;
anyhow::ensure!(
ver >= vec![27, 0],
"Server version {} not supported - need 27.0 minimum.",
Expand Down Expand Up @@ -255,7 +256,9 @@ impl RsyncClient {
mtime_buf
} else {
let ts = read.read_i32_le().await?;
#[allow(deprecated)]
let naive = NaiveDateTime::from_timestamp(ts as i64, 0);
#[allow(deprecated)]
let datetime: DateTime<Utc> = DateTime::from_utc(naive, Utc);
Some(datetime)
};
Expand Down Expand Up @@ -298,7 +301,7 @@ impl RsyncClient {
}
ret.sort_unstable_by(|a, b| a.path.cmp(&b.path));
// Hmm. rsyn also dedupes. I've never seen dupes, so I don't know why.
for (i, mut f) in ret.iter_mut().enumerate() {
for (i, f) in ret.iter_mut().enumerate() {
f.idx = i;
log::debug!("{:>6} {}", f.idx, f);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/arrsync/src/receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl RequestsInner {
}

pub fn refresh_timeout(&mut self) {
for to in self.timeout.as_mut() {
if let Some(to) = self.timeout.as_mut() {
*to = Self::timeout();
}
}
Expand Down

0 comments on commit 4a0b557

Please sign in to comment.