MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / store_change

Method store_change

atomic-remote/src/http/upload.rs:99–130  ·  view source on GitHub ↗

Store a change file on the remote without applying it to any view. Content-only companion to [`Self::upload_change`]: the server writes the change file (content-addressed, idempotent — 200 if it already exists) but does not touch any view's change log. View membership is declared separately via [`Self::put_view_manifest`], which is what makes the store/declare split safe: a view is never half-cre

(&self, hash: &str, data: Bytes)

Source from the content-addressed store, hash-verified

97 /// makes the store/declare split safe: a view is never half-created
98 /// with guessed identity.
99 pub async fn store_change(&self, hash: &str, data: Bytes) -> RemoteResult<()> {
100 let url = format!("{}?store={}", self.base_url, hash);
101 debug!("POST store: {} ({} bytes)", url, data.len());
102
103 let response = self
104 .client
105 .post(&url)
106 .header(CONTENT_TYPE, "application/octet-stream")
107 .body(data)
108 .send()
109 .await
110 .map_err(|e| RemoteError::connection_failed(&url, e))?;
111
112 crate::check_min_version_header(response.headers());
113 let status = response.status();
114
115 match status {
116 StatusCode::OK => {
117 debug!("Successfully stored change {}", hash);
118 Ok(())
119 }
120 StatusCode::NOT_FOUND => Err(RemoteError::repo_not_found(&url)),
121 StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN => {
122 let msg = response.text().await.unwrap_or_default();
123 Err(RemoteError::auth_failed(&url, msg))
124 }
125 _ => {
126 let msg = response.text().await.unwrap_or_default();
127 Err(RemoteError::http(status.as_u16(), msg))
128 }
129 }
130 }
131
132 /// Declare a view's identity and change log on the remote.
133 ///

Callers 1

run_asyncMethod · 0.80

Calls 5

check_min_version_headerFunction · 0.85
postMethod · 0.80
textMethod · 0.80
headerMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected