feat: initial support for segatools pkgs

This commit is contained in:
2025-03-15 00:08:33 +01:00
parent b525e74467
commit caa20a3aa0
20 changed files with 246 additions and 112 deletions

View File

@ -120,13 +120,14 @@ impl PackageStore {
}
pub async fn install_package(&mut self, key: &PkgKey, force: bool, install_deps: bool) -> Result<InstallResult> {
log::debug!("Installing {}", key);
log::info!("installation request: {}/{}/{}", key, force, install_deps);
let pkg = self.store.get(key)
.ok_or_else(|| anyhow!("Attempted to install a nonexistent pkg"))?
.clone();
if pkg.loc.is_some() && !force {
log::debug!("installation skipped");
return Ok(InstallResult::Ready);
}
@ -152,7 +153,7 @@ impl PackageStore {
if !zip_path.exists() {
self.dlh.download_zip(&zip_path, &pkg)?;
log::debug!("Deferring {}", key);
log::debug!("deferring {}", key);
return Ok(InstallResult::Deferred);
}
@ -170,13 +171,13 @@ impl PackageStore {
pkg: key.to_owned()
})?;
log::info!("Installed {}", key);
log::info!("installed {}", key);
Ok(InstallResult::Ready)
}
pub async fn delete_package(&mut self, key: &PkgKey, force: bool) -> Result<()> {
log::debug!("Will delete {} {}", key, force);
log::debug!("will delete {} {}", key, force);
let pkg = self.store.get_mut(key)
.ok_or_else(|| anyhow!("Attempted to delete a nonexistent pkg"))?;
@ -191,7 +192,7 @@ impl PackageStore {
self.app.emit("install-end", Payload {
pkg: key.to_owned()
})?;
log::info!("Deleted {}", key);
log::info!("deleted {}", key);
}
rv
} else {
@ -216,7 +217,7 @@ impl PackageStore {
if path.exists() {
tokio::fs::remove_dir_all(path)
.await
.map_err(|e| anyhow!("Could not delete /{}: {}", name, e))?;
.map_err(|e| anyhow!("could not delete {}: {}", name, e))?;
}
Ok(())
@ -237,6 +238,7 @@ impl PackageStore {
// todo case sensitivity for linux
Self::clean_up_dir(&path, "app").await?;
Self::clean_up_dir(&path, "option").await?;
Self::clean_up_dir(&path, "segatools").await?;
Self::clean_up_file(&path, "icon.png", true).await?;
Self::clean_up_file(&path, "manifest.json", true).await?;
Self::clean_up_file(&path, "README.md", true).await?;