src/client/http_client.rs: automatically close connection in finish
This commit is contained in:
parent
cb4426b348
commit
4247fccb0f
@ -476,7 +476,6 @@ fn create_backup(
|
|||||||
}
|
}
|
||||||
|
|
||||||
client.finish().wait()?;
|
client.finish().wait()?;
|
||||||
client.force_close();
|
|
||||||
|
|
||||||
let end_time = Local.timestamp(Local::now().timestamp(), 0);
|
let end_time = Local.timestamp(Local::now().timestamp(), 0);
|
||||||
let elapsed = end_time.signed_duration_since(backup_time);
|
let elapsed = end_time.signed_duration_since(backup_time);
|
||||||
|
@ -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> {
|
pub fn get(&self, path: &str, param: Option<Value>) -> impl Future<Item=Value, Error=Error> {
|
||||||
self.h2.get(path, param)
|
self.h2.get(path, param)
|
||||||
}
|
}
|
||||||
@ -444,8 +440,16 @@ impl BackupClient {
|
|||||||
self.h2.post(path, param)
|
self.h2.post(path, param)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn finish(&self) -> impl Future<Item=(), Error=Error> {
|
pub fn finish(mut self) -> impl Future<Item=(), Error=Error> {
|
||||||
self.h2.clone().post("finish", None).map(|_| ())
|
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>>(
|
pub fn upload_config<P: AsRef<std::path::Path>>(
|
||||||
|
Loading…
Reference in New Issue
Block a user