MCPcopy Create free account
hub / github.com/Moosync/Moosync / download_extension

Method download_extension

src-tauri/extensions/src/lib.rs:225–249  ·  view source on GitHub ↗
(&self, fetched_ext: FetchedExtensionManifest)

Source from the content-addressed store, hash-verified

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;

Callers

nothing calls this directly

Calls 2

cloneMethod · 0.80
install_extensionMethod · 0.80

Tested by

no test coverage detected