summaryrefslogtreecommitdiff
path: root/src/types.rs
diff options
context:
space:
mode:
authorNaz <ndpm13@ch-naseem.com>2025-07-28 09:50:56 +0100
committerNaz <ndpm13@ch-naseem.com>2025-07-28 09:50:56 +0100
commit91813e3f6a9b93b92fb4b99d2e9512d41726c9d9 (patch)
tree700a978fb913a08e4bbbccdcc202aac70e40e7fe /src/types.rs
parenta77624b8615a10d6aaba186dcd6bbb15b1419397 (diff)
✨feat: add AppImage removal functionality
Diffstat (limited to 'src/types.rs')
-rw-r--r--src/types.rs19
1 files changed, 15 insertions, 4 deletions
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,
}
@@ -92,4 +92,15 @@ impl AppImage {
Ok(())
}
+ pub async fn remove(&self) -> Result<(), Box<dyn std::error::Error>> {
+ 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(())
+ }
}