summaryrefslogtreecommitdiff
path: root/src/ci_runner.rs
diff options
context:
space:
mode:
authoriximeow <git@iximeow.net>2022-12-29 09:19:07 +0000
committeriximeow <git@iximeow.net>2022-12-29 09:19:07 +0000
commite28b277980763b88d2828812bff2c0b9546d3d25 (patch)
tree34fe85309adb4170662951b3fb179f7441631e22 /src/ci_runner.rs
parent7801ace71a60f9c16497d99f760c14529a2d63d3 (diff)
do not use buggy AsyncWrite impl for file transfer, spawn_blocking a blocking task
Diffstat (limited to 'src/ci_runner.rs')
-rw-r--r--src/ci_runner.rs41
1 files changed, 3 insertions, 38 deletions
diff --git a/src/ci_runner.rs b/src/ci_runner.rs
index 3c0104f..a47d298 100644
--- a/src/ci_runner.rs
+++ b/src/ci_runner.rs
@@ -16,6 +16,8 @@ use std::marker::Unpin;
mod lua;
mod io;
+use crate::io::ArtifactStream;
+
#[derive(Debug)]
enum WorkAcquireError {
Reqwest(reqwest::Error),
@@ -100,9 +102,7 @@ impl RunningJob {
if resp.status() == StatusCode::OK {
eprintln!("[+] artifact '{}' started", name);
- Ok(ArtifactStream {
- sender,
- })
+ Ok(ArtifactStream::new(sender))
} else {
Err(format!("[-] unable to create artifact: {:?}", resp))
}
@@ -319,41 +319,6 @@ impl RunningJob {
}
}
-struct ArtifactStream {
- sender: hyper::body::Sender,
-}
-
-impl tokio::io::AsyncWrite for ArtifactStream {
- fn poll_write(
- self: Pin<&mut Self>,
- cx: &mut Context,
- buf: &[u8]
- ) -> Poll<Result<usize, std::io::Error>> {
- match self.get_mut().sender.try_send_data(buf.to_vec().into()) {
- Ok(()) => {
- Poll::Ready(Ok(buf.len()))
- },
- _ => {
- Poll::Pending
- }
- }
- }
-
- fn poll_flush(
- self: Pin<&mut Self>,
- _cx: &mut Context
- ) -> Poll<Result<(), std::io::Error>> {
- Poll::Ready(Ok(()))
- }
-
- fn poll_shutdown(
- self: Pin<&mut Self>,
- _cx: &mut Context
- ) -> Poll<Result<(), std::io::Error>> {
- Poll::Ready(Ok(()))
- }
-}
-
impl RunnerClient {
async fn new(host: &str, mut sender: hyper::body::Sender, mut res: Response) -> Result<Self, String> {
if res.status() != StatusCode::OK {