8000 feat(minimal): upload project files to session on activate by 0chroma · Pull Request #748 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/minimal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ remote-access = []

[dependencies]
anyhow.workspace = true
async-compression.workspace = true
async-tar.workspace = true
clap.workspace = true
clap_complete.workspace = true
camino.workspace = true
chrono.workspace = true
constcat.workspace = true
dirs.workspace = true
mctx.workspace = true
mfile.workspace = true
Expand Down
37 changes: 37 additions & 0 deletions crates/minimal/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,43 @@ impl Client {
serde_json::from_slice(&resp_buf)
.with_context(|| format!("decode response for {}", R::NAME))
}

/// Stream a zstd-compressed tarball of `dir` to the daemon's
/// `WorkspaceFilesTarZst` subsystem, which unpacks it into the
/// session's workspace directory.
///
/// `session_id` is set as the `MINIMAL_SESSION_ID` env var on the
/// channel so the daemon can scope the upload to the correct session.
pub async fn upload_workspace_files(
&mut self,
session_id: sessions::SessionId,
dir: &Path,
) -> Result<(), anyhow::Error> {
let subsystem =
constcat::concat!(minimald_rpc::RPC_SUBSYSTEM_PREFIX, "WorkspaceFilesTarZst");

let channel = self
.handle
.channel_open_session()
.await
.context("open channel for workspace file upload")?;

channel
.set_env(true, "MINIMAL_SESSION_ID", session_id.to_string())
.await
.context("set MINIMAL_SESSION_ID env")?;

channel
.request_subsystem(true, subsystem)
.await
.context("request WorkspaceFilesTarZst subsystem")?;

let stream = channel.into_stream();

// Stream a tar+zstd archive directly to the daemon channel,
// avoiding buffering the entire archive in memory.
crate::file_upload::stream_tar_zstd(dir, stream).await
}
}

/// Resolve the provider-instance dir (`<state dir>/providers/local-0`) the
Expand Down
Loading
Loading
0