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)
| 74 | /// makes the store/declare split safe: a view is never half-created |
| 75 | /// with guessed identity. |
| 76 | pub async fn store_change(&self, hash: &str, data: Bytes) -> RemoteResult<()> { |
| 77 | let url = format!("{}?store={}", self.base_url, hash); |
| 78 | debug!("POST store: {} ({} bytes)", url, data.len()); |
| 79 | |
| 80 | let response = self |
| 81 | .client |
| 82 | .post(&url) |
| 83 | .header(CONTENT_TYPE, "application/octet-stream") |
| 84 | .body(data) |
| 85 | .send() |
| 86 | .await |
| 87 | .map_err(|e| RemoteError::connection_failed(&url, e))?; |
| 88 | |
| 89 | crate::check_min_version_header(response.headers()); |
| 90 | let status = response.status(); |
| 91 | |
| 92 | match status { |
| 93 | StatusCode::OK => { |
| 94 | debug!("Successfully stored change {}", hash); |
| 95 | Ok(()) |
| 96 | } |
| 97 | StatusCode::NOT_FOUND => Err(RemoteError::repo_not_found(&url)), |
| 98 | StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN => { |
| 99 | let msg = response.text().await.unwrap_or_default(); |
| 100 | Err(RemoteError::auth_failed(&url, msg)) |
| 101 | } |
| 102 | _ => { |
| 103 | let msg = response.text().await.unwrap_or_default(); |
| 104 | Err(RemoteError::http(status.as_u16(), msg)) |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | /// Declare a view's identity and change log on the remote. |
| 110 | /// |