(&self, fetched_ext: FetchedExtensionManifest)
| 223 | |
| 224 | #[tracing::instrument(level = "debug", skip(self, fetched_ext))] |
| 225 | pub async fn download_extension(&self, fetched_ext: FetchedExtensionManifest) -> Result<()> { |
| 226 | let parsed_url = fetched_ext.url; |
| 227 | let file_path = self.tmp_dir.join(format!( |
| 228 | "{}-{}.msox", |
| 229 | fetched_ext.package_name, |
| 230 | uuid::Uuid::new_v4() |
| 231 | )); |
| 232 | |
| 233 | tracing::info!("parsed url {}. Saving at {:?}", parsed_url, file_path); |
| 234 | |
| 235 | let mut stream = reqwest::get(parsed_url).await?.bytes_stream(); |
| 236 | let mut file = File::create(file_path.clone())?; |
| 237 | |
| 238 | while let Some(chunk_result) = stream.next().await { |
| 239 | let chunk = chunk_result?; |
| 240 | file.write_all(&chunk)?; |
| 241 | } |
| 242 | |
| 243 | tracing::info!("Wrote file"); |
| 244 | |
| 245 | self.install_extension(file_path.to_string_lossy().to_string()) |
| 246 | .await?; |
| 247 | |
| 248 | Ok(()) |
| 249 | } |
| 250 | |
| 251 | async fn send_remove_extension(&self, package_name: PackageNameArgs) -> Result<()> { |
| 252 | let mut inner = self.inner.lock().await; |
nothing calls this directly
no test coverage detected