diff --git a/Makefile b/Makefile index 2599742dd..0096d1615 100644 --- a/Makefile +++ b/Makefile @@ -378,10 +378,13 @@ cargo-deps/aarch64-unknown-linux-musl/release/pi-beep: ./build-cargo-dep.sh ARCH=aarch64 ./build-cargo-dep.sh pi-beep cargo-deps/$(RUST_ARCH)-unknown-linux-musl/release/tokio-console: ./build-cargo-dep.sh - ARCH=$(ARCH) PREINSTALL="apk add musl-dev pkgconfig" ./build-cargo-dep.sh tokio-console + ARCH=$(ARCH) ./build-cargo-dep.sh tokio-console + touch $@ cargo-deps/$(RUST_ARCH)-unknown-linux-musl/release/startos-backup-fs: ./build-cargo-dep.sh - ARCH=$(ARCH) PREINSTALL="apk add fuse3 fuse3-dev fuse3-static musl-dev pkgconfig" ./build-cargo-dep.sh --git https://github.com/Start9Labs/start-fs.git startos-backup-fs + ARCH=$(ARCH) ./build-cargo-dep.sh --git https://github.com/Start9Labs/start-fs.git startos-backup-fs + touch $@ cargo-deps/$(RUST_ARCH)-unknown-linux-musl/release/flamegraph: ./build-cargo-dep.sh - ARCH=$(ARCH) PREINSTALL="apk add musl-dev pkgconfig" ./build-cargo-dep.sh flamegraph + ARCH=$(ARCH) ./build-cargo-dep.sh flamegraph + touch $@ diff --git a/build-cargo-dep.sh b/build-cargo-dep.sh index 1abb0d279..3ac4770ab 100755 --- a/build-cargo-dep.sh +++ b/build-cargo-dep.sh @@ -25,5 +25,5 @@ RUSTFLAGS="-C target-feature=+crt-static" rust-zig-builder cargo-zigbuild install $* --target-dir /workdir/cargo-deps/ --target=$RUST_ARCH-unknown-linux-musl if [ "$(ls -nd "cargo-deps/$RUST_ARCH-unknown-linux-musl/release/${!#}" | awk '{ print $3 }')" != "$UID" ]; then - rust-zig-builder sh -c "chown -R $UID:$UID core/target && chown -R $UID:$UID /usr/local/cargo" + rust-zig-builder sh -c "chown -R $UID:$UID cargo-deps && chown -R $UID:$UID /usr/local/cargo" fi diff --git a/core/startos/src/context/rpc.rs b/core/startos/src/context/rpc.rs index ee0bc1420..6dda9fc7e 100644 --- a/core/startos/src/context/rpc.rs +++ b/core/startos/src/context/rpc.rs @@ -389,12 +389,19 @@ impl RpcContext { .as_entries()? .into_iter() .map(|(_, pde)| { - Ok(pde.as_tasks().as_entries()?.into_iter().map(|(_, r)| { - Ok::<_, Error>(( - r.as_task().as_package_id().de()?, - r.as_task().as_action_id().de()?, - )) - })) + Ok(pde + .as_tasks() + .as_entries()? + .into_iter() + .map(|(_, r)| { + let t = r.as_task(); + Ok::<_, Error>(if t.as_input().transpose_ref().is_some() { + Some((t.as_package_id().de()?, t.as_action_id().de()?)) + } else { + None + }) + }) + .filter_map_ok(|a| a)) }) .flatten_ok() .map(|a| a.and_then(|a| a)) diff --git a/core/startos/src/service/mod.rs b/core/startos/src/service/mod.rs index 4894b99d5..e4d2ba0df 100644 --- a/core/startos/src/service/mod.rs +++ b/core/startos/src/service/mod.rs @@ -298,7 +298,8 @@ impl Service { return Ok(None); }; let s9pk_path = entry.as_s9pk().de()?; - match entry.as_state_info().as_match() { + let state = entry.as_state_info().as_match(); + match state { PackageStateMatchModelRef::Installing(_) => { if disposition == LoadDisposition::Retry { if let Ok(s9pk) = S9pk::open(&s9pk_path, Some(id)).await.map_err(|e| { @@ -432,11 +433,10 @@ impl Service { } } - if disposition == LoadDisposition::Retry { - ctx.db - .mutate(|v| v.as_public_mut().as_package_data_mut().remove(id)) - .await - .result?; + if disposition == LoadDisposition::Retry + || matches!(state, PackageStateMatchModelRef::Restoring(_)) + { + cleanup(ctx, id, false).await?; } Ok(None) @@ -493,11 +493,16 @@ impl Service { .as_entries()? .into_iter() .map(|(_, r)| { - Ok::<_, Error>(if r.as_task().as_package_id().de()? == manifest.id { - Some(r.as_task().as_action_id().de()?) - } else { - None - }) + let t = r.as_task(); + Ok::<_, Error>( + if t.as_package_id().de()? == manifest.id + && t.as_input().transpose_ref().is_some() + { + Some(t.as_action_id().de()?) + } else { + None + }, + ) }) .filter_map_ok(|a| a)) }) @@ -515,7 +520,9 @@ impl Service { { if let Some(input) = service .get_action_input(procedure_id.clone(), action_id.clone()) - .await? + .await + .log_err() + .flatten() .and_then(|i| i.value) { action_input.insert(action_id, input); @@ -589,7 +596,7 @@ impl Service { .send( Guid::new(), transition::backup::Backup { - path: guard.path().to_owned(), + path: guard.path().join("data"), }, ) .await??; diff --git a/core/startos/src/status/mod.rs b/core/startos/src/status/mod.rs index 5fd03f14d..c9142c57b 100644 --- a/core/startos/src/status/mod.rs +++ b/core/startos/src/status/mod.rs @@ -35,6 +35,12 @@ impl Model { pub fn started(&mut self) -> Result<(), Error> { self.as_started_mut() .map_mutate(|s| Ok(Some(s.unwrap_or_else(|| Utc::now()))))?; + self.as_desired_mut().map_mutate(|s| { + Ok(match s { + DesiredStatus::Restarting => DesiredStatus::Running, + a => a, + }) + })?; Ok(()) } pub fn stop(&mut self) -> Result<(), Error> { diff --git a/sdk/package/lib/backup/Backups.ts b/sdk/package/lib/backup/Backups.ts index 73a6c9dcf..8594f3f8f 100644 --- a/sdk/package/lib/backup/Backups.ts +++ b/sdk/package/lib/backup/Backups.ts @@ -205,11 +205,11 @@ async function runRsync(rsyncOptions: { const spawned = child_process.spawn(command, args, { detached: true }) let percentage = 0.0 spawned.stdout.on("data", (data: unknown) => { - const lines = String(data).replace("\r", "\n").split("\n") + const lines = String(data).replace(/\r/g, "\n").split("\n") for (const line of lines) { const parsed = /$([0-9.]+)%/.exec(line)?.[1] if (!parsed) { - console.log(parsed) + console.log(line) continue } percentage = Number.parseFloat(parsed)