Add raw handling to process actor

This commit is contained in:
Nadja Reitzenstein 2023-01-18 16:26:09 +01:00
parent b8092e9090
commit 5fdfae295a
3 changed files with 37 additions and 23 deletions

17
Cargo.lock generated
View File

@ -425,6 +425,12 @@ version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
[[package]]
name = "base64"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a"
[[package]] [[package]]
name = "bitfield" name = "bitfield"
version = "0.13.2" version = "0.13.2"
@ -999,6 +1005,7 @@ dependencies = [
"async-process", "async-process",
"async-trait", "async-trait",
"backtrace", "backtrace",
"base64 0.21.0",
"capnp", "capnp",
"capnp-rpc", "capnp-rpc",
"chrono", "chrono",
@ -1467,7 +1474,7 @@ version = "7.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ea9fe3952d32674a14e0975009a3547af9ea364995b5ec1add2e23c2ae523ab" checksum = "6ea9fe3952d32674a14e0975009a3547af9ea364995b5ec1add2e23c2ae523ab"
dependencies = [ dependencies = [
"base64", "base64 0.13.0",
"byteorder", "byteorder",
"crossbeam-channel", "crossbeam-channel",
"flate2", "flate2",
@ -2541,7 +2548,7 @@ version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb"
dependencies = [ dependencies = [
"base64", "base64 0.13.0",
"blake2b_simd", "blake2b_simd",
"constant_time_eq", "constant_time_eq",
"crossbeam-utils", "crossbeam-utils",
@ -2583,7 +2590,7 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ee86d63972a7c661d1536fefe8c3c8407321c3df668891286de28abcd087360" checksum = "1ee86d63972a7c661d1536fefe8c3c8407321c3df668891286de28abcd087360"
dependencies = [ dependencies = [
"base64", "base64 0.13.0",
] ]
[[package]] [[package]]
@ -2592,7 +2599,7 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0864aeff53f8c05aa08d86e5ef839d3dfcf07aeba2db32f12db0ef716e87bd55" checksum = "0864aeff53f8c05aa08d86e5ef839d3dfcf07aeba2db32f12db0ef716e87bd55"
dependencies = [ dependencies = [
"base64", "base64 0.13.0",
] ]
[[package]] [[package]]
@ -3135,7 +3142,7 @@ dependencies = [
"async-stream", "async-stream",
"async-trait", "async-trait",
"axum", "axum",
"base64", "base64 0.13.0",
"bytes", "bytes",
"futures-core", "futures-core",
"futures-util", "futures-util",

View File

@ -43,6 +43,7 @@ backtrace = "0.3.65"
miette = { version = "4.7.1", features = ["fancy"] } miette = { version = "4.7.1", features = ["fancy"] }
thiserror = "1.0.31" thiserror = "1.0.31"
toml = "0.5.8" toml = "0.5.8"
base64 = "0.21"
# Well-known paths/dirs for e.g. cache # Well-known paths/dirs for e.g. cache
dirs = "4.0.0" dirs = "4.0.0"

View File

@ -1,6 +1,7 @@
use futures_util::future::BoxFuture; use futures_util::future::BoxFuture;
use std::collections::HashMap; use std::collections::HashMap;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use base64::Engine;
use crate::actors::Actor; use crate::actors::Actor;
use crate::db::ArchivedValue; use crate::db::ArchivedValue;
@ -39,6 +40,7 @@ impl Actor for Process {
.args(self.args.iter()) .args(self.args.iter())
.arg(&self.name); .arg(&self.name);
if state.as_ref().raw.is_empty() {
match &state.as_ref().inner.state { match &state.as_ref().inner.state {
ArchivedStatus::Free => { ArchivedStatus::Free => {
command.arg("free"); command.arg("free");
@ -59,6 +61,10 @@ impl Actor for Process {
command.arg("reserved").arg(by.id.as_str()); command.arg("reserved").arg(by.id.as_str());
} }
} }
} else {
let b64 = base64::prelude::BASE64_STANDARD_NO_PAD.encode(&state.as_ref().raw);
command.arg("raw").arg(b64);
}
let name = self.name.clone(); let name = self.name.clone();
Box::pin(async move { Box::pin(async move {