protocol: cleanup finish_backup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-03-13 14:15:30 +01:00
parent b238851832
commit 6f90a6a764
2 changed files with 6 additions and 5 deletions

View File

@ -587,17 +587,17 @@ where
self.common.queue_data(packet.finish()) self.common.queue_data(packet.finish())
} }
pub fn finish_backup(&mut self, stream: BackupStream) -> Result<(StreamId, String, bool)> { pub fn finish_backup(&mut self, stream: BackupStream) -> Result<(String, bool)> {
let path = self let path = self
.streams .streams
.remove(&stream.0) .remove(&stream.0)
.ok_or_else(|| format_err!("no such active backup stream"))? .ok_or_else(|| format_err!("no such active backup stream"))?
.path .path
.unwrap_or_else(|| "<no remote name received>".to_string()); .unwrap_or_else(|| "<no remote name received>".to_string());
let ack = self let done = self
.common .common
.queue_data(Packet::simple(stream.0, PacketType::BackupFinished))?; .queue_data(Packet::simple(stream.0, PacketType::BackupFinished))?;
self.expect_ok_for_id(stream.0); self.expect_ok_for_id(stream.0);
Ok((StreamId(stream.0), path, ack)) Ok((path, done))
} }
} }

View File

@ -240,9 +240,10 @@ impl<S: AsyncRead + AsyncWrite> UploaderBase<S> {
} }
pub fn finish_backup(&mut self, stream: BackupStream) -> Result<(), Error> { pub fn finish_backup(&mut self, stream: BackupStream) -> Result<(), Error> {
let (ack, name, _done) = self.client.as_mut().unwrap().finish_backup(stream)?; let id = stream.into();
let (name, _done) = self.client.as_mut().unwrap().finish_backup(stream)?;
println!("Server created file: {}", name); println!("Server created file: {}", name);
self.wait_id = Some(ack); self.wait_id = Some(id);
Ok(()) Ok(())
} }