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)
| 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 | /// |