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

Method download_change_layers

atomic-remote/src/http/download.rs:109–153  ·  view source on GitHub ↗

Download a change with layer-selective filtering. Uses the `?layers=` query parameter to request only specific layers from the server. This enables: - **Thin pull** (`layers=graph,content`): Download only what's needed to apply the change, skipping the semantic layer (~40% smaller). - **Thin review** (`layers=semantic,content`): Download only what's needed for code review, skipping graph ops (~6

(
        &self,
        hash: &str,
        layers: &LayerSelection,
    )

Source from the content-addressed store, hash-verified

107 /// The raw change data (may be a subset of the full change if the
108 /// server supports layer-selective responses).
109 pub async fn download_change_layers(
110 &self,
111 hash: &str,
112 layers: &LayerSelection,
113 ) -> RemoteResult<Bytes> {
114 let layers_param = layers.to_query_value();
115 let url = format!("{}?change={}&layers={}", self.base_url, hash, layers_param);
116 debug!("GET change (layers={}): {}", layers_param, url);
117
118 let response = self
119 .client
120 .get(&url)
121 .send()
122 .await
123 .map_err(|e| RemoteError::connection_failed(&url, e))?;
124
125 crate::check_min_version_header(response.headers());
126 let status = response.status();
127
128 match status {
129 StatusCode::OK => {
130 let bytes = response
131 .bytes()
132 .await
133 .map_err(|e| RemoteError::connection_failed(&url, e))?;
134
135 debug!(
136 "Downloaded change {} (layers={}): {} bytes",
137 hash,
138 layers_param,
139 bytes.len()
140 );
141 Ok(bytes)
142 }
143 StatusCode::NOT_FOUND => Err(RemoteError::change_not_found(hash)),
144 StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN => {
145 let msg = response.text().await.unwrap_or_default();
146 Err(RemoteError::auth_failed(&url, msg))
147 }
148 _ => {
149 let msg = response.text().await.unwrap_or_default();
150 Err(RemoteError::http(status.as_u16(), msg))
151 }
152 }
153 }
154
155 /// Get the chunk manifest for a change.
156 ///

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected