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

Method download_change

atomic-remote/src/http/queries.rs:174–208  ·  view source on GitHub ↗

Download a change file by hash. # Arguments `hash` - The base32-encoded hash of the change. # Returns The raw change file data.

(&self, hash: &str)

Source from the content-addressed store, hash-verified

172 ///
173 /// The raw change file data.
174 pub async fn download_change(&self, hash: &str) -> RemoteResult<Bytes> {
175 let url = format!("{}?change={}", self.base_url, hash);
176 debug!("GET change: {}", url);
177
178 let response = self
179 .client
180 .get(&url)
181 .send()
182 .await
183 .map_err(|e| RemoteError::connection_failed(&url, e))?;
184
185 crate::check_min_version_header(response.headers());
186 let status = response.status();
187
188 match status {
189 StatusCode::OK => {
190 let bytes = response
191 .bytes()
192 .await
193 .map_err(|e| RemoteError::connection_failed(&url, e))?;
194
195 debug!("Downloaded change {}: {} bytes", hash, bytes.len());
196 Ok(bytes)
197 }
198 StatusCode::NOT_FOUND => Err(RemoteError::change_not_found(hash)),
199 StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN => {
200 let msg = response.text().await.unwrap_or_default();
201 Err(RemoteError::auth_failed(&url, msg))
202 }
203 _ => {
204 let msg = response.text().await.unwrap_or_default();
205 Err(RemoteError::http(status.as_u16(), msg))
206 }
207 }
208 }
209
210 /// Download a tag by state (short format).
211 ///

Callers 2

run_asyncMethod · 0.80
run_asyncMethod · 0.80

Calls 4

check_min_version_headerFunction · 0.85
textMethod · 0.80
getMethod · 0.65
statusMethod · 0.45

Tested by

no test coverage detected