MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / push_restore

Function push_restore

nodedb/tests/sql_backup_restore_wire.rs:41–61  ·  view source on GitHub ↗
(
    server: &TestServer,
    tenant: u64,
    bytes: Vec<u8>,
    dry_run: bool,
)

Source from the content-addressed store, hash-verified

39}
40
41async fn push_restore(
42 server: &TestServer,
43 tenant: u64,
44 bytes: Vec<u8>,
45 dry_run: bool,
46) -> Result<(), String> {
47 use futures::SinkExt;
48
49 let suffix = if dry_run { " DRY RUN" } else { "" };
50 let sink = server
51 .client
52 .copy_in::<_, Bytes>(&format!("COPY tenant_restore({tenant}) FROM STDIN{suffix}"))
53 .await
54 .map_err(detail)?;
55 let mut sink = Box::pin(sink);
56 sink.as_mut()
57 .send(Bytes::from(bytes))
58 .await
59 .map_err(detail)?;
60 sink.as_mut().finish().await.map(|_| ()).map_err(detail)
61}
62
63/// Extract the server-side error detail from a tokio_postgres error.
64/// `e.to_string()` returns "db error"; the actual message lives on

Calls 2

sendMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected