From 91813e3f6a9b93b92fb4b99d2e9512d41726c9d9 Mon Sep 17 00:00:00 2001 From: Naz Date: Mon, 28 Jul 2025 09:50:56 +0100 Subject: =?UTF-8?q?=E2=9C=A8feat:=20add=20AppImage=20removal=20functionali?= =?UTF-8?q?ty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/types.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/types.rs') diff --git a/src/types.rs b/src/types.rs index f0cbfd4..be3f3ed 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,24 +1,24 @@ use futures_util::StreamExt; -use serde::Serialize; +use serde::{Serialize, Deserialize}; use std::path::PathBuf; use tokio::{fs, io::AsyncWriteExt}; use crate::{appimages_dir, index_dir, make_progress_bar}; -#[derive(Debug, Serialize)] +#[derive(Debug, Serialize, Deserialize)] pub struct AppImage { pub file_path: PathBuf, pub executable: String, pub source: Source, } -#[derive(Debug, Serialize)] +#[derive(Debug, Serialize, Deserialize)] pub struct Source { pub identifier: String, pub meta: SourceMetadata, } -#[derive(Debug, Serialize)] +#[derive(Debug, Serialize, Deserialize)] pub struct SourceMetadata { pub url: String, } @@ -90,6 +90,17 @@ impl AppImage { std::os::unix::fs::symlink(&self.file_path, &symlink_path)?; } + Ok(()) + } + pub async fn remove(&self) -> Result<(), Box> { + let home = std::env::var("HOME")?; + let symlink_path = PathBuf::from(home).join(".local/bin").join(&self.executable); + let index_path = index_dir().join(format!("{}.json", &self.executable)); + + fs::remove_file(&self.file_path).await?; + fs::remove_file(symlink_path).await?; + fs::remove_file(index_path).await?; + Ok(()) } } -- cgit v1.2.3