src/client/http_client.rs: automatically close connection in finish

This commit is contained in:
Dietmar Maurer 2019-06-05 11:41:50 +02:00
parent cb4426b348
commit 4247fccb0f
2 changed files with 10 additions and 7 deletions

View File

@ -476,7 +476,6 @@ fn create_backup(
}
client.finish().wait()?;
client.force_close();
let end_time = Local.timestamp(Local::now().timestamp(), 0);
let elapsed = end_time.signed_duration_since(backup_time);

View File

@ -428,10 +428,6 @@ impl BackupClient {
}
}
pub fn force_close(mut self) {
self.canceller.take().unwrap().cancel();
}
pub fn get(&self, path: &str, param: Option<Value>) -> impl Future<Item=Value, Error=Error> {
self.h2.get(path, param)
}
@ -444,8 +440,16 @@ impl BackupClient {
self.h2.post(path, param)
}
pub fn finish(&self) -> impl Future<Item=(), Error=Error> {
self.h2.clone().post("finish", None).map(|_| ())
pub fn finish(mut self) -> impl Future<Item=(), Error=Error> {
let canceler = self.canceller.take().unwrap();
self.h2.clone().post("finish", None).map(move |_| {
canceler.cancel();
()
})
}
pub fn force_close(mut self) {
self.canceller.take().unwrap().cancel();
}
pub fn upload_config<P: AsRef<std::path::Path>>(