use existing dependency icon if available (#2489)

This commit is contained in:
Aiden McClelland
2023-11-01 13:23:14 -06:00
committed by GitHub
parent 2b9e7432b8
commit c14ca1d7fd

View File

@@ -838,15 +838,15 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin + Send + Sync>(
None None
}; };
let icon_path = if let Some(marketplace_url) = &marketplace_url { let icon_path = if let Some(manifest) = &manifest {
if let Some(manifest) = &manifest { let dir = ctx
let dir = ctx .datadir
.datadir .join(PKG_PUBLIC_DIR)
.join(PKG_PUBLIC_DIR) .join(&manifest.id)
.join(&manifest.id) .join(manifest.version.as_str());
.join(manifest.version.as_str()); let icon_path = dir.join(format!("icon.{}", manifest.assets.icon_type()));
let icon_path = dir.join(format!("icon.{}", manifest.assets.icon_type())); if tokio::fs::metadata(&icon_path).await.is_err() {
if tokio::fs::metadata(&icon_path).await.is_err() { if let Some(marketplace_url) = &marketplace_url {
tokio::fs::create_dir_all(&dir).await?; tokio::fs::create_dir_all(&dir).await?;
let icon = ctx let icon = ctx
.client .client
@@ -864,10 +864,12 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin + Send + Sync>(
let mut dst = File::create(&icon_path).await?; let mut dst = File::create(&icon_path).await?;
tokio::io::copy(&mut response_to_reader(icon), &mut dst).await?; tokio::io::copy(&mut response_to_reader(icon), &mut dst).await?;
dst.sync_all().await?; dst.sync_all().await?;
Some(icon_path)
} else {
None
} }
Some(icon_path)
} else { } else {
None Some(icon_path)
} }
} else { } else {
None None