diff options
| author | Naz <ndpm13@ch-naseem.com> | 2025-07-29 16:27:18 +0100 |
|---|---|---|
| committer | Naz <ndpm13@ch-naseem.com> | 2025-07-29 16:27:18 +0100 |
| commit | 2cef21906b9bd3c2e92925d7c93d3c8053b52ade (patch) | |
| tree | afded3e5c0fa598cc271be925cfe4ccca7c4b9f0 /src | |
| parent | cd49bc9362c0fef2534948d368c8c52460558a77 (diff) | |
🔧refactor: move the rest of the indexing relating logic to Index
Diffstat (limited to 'src')
| -rw-r--r-- | src/index.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/index.rs b/src/index.rs index e543b1d..069068a 100644 --- a/src/index.rs +++ b/src/index.rs @@ -9,6 +9,16 @@ impl Index { pub fn new() -> Self { Self {} } + pub async fn get(&self, appname: &str) -> Result<AppImage, Box<dyn std::error::Error>> { + let index_file_path = index_dir().join(format!("{appname}.json")); + let index_file_content = fs::read_to_string(&index_file_path).await?; + let appimage: AppImage = serde_json::from_str(&index_file_content)?; + + Ok(appimage) + } + pub fn exists(&self, executable: &str) -> bool { + index_dir().join(format!("{}.json", &executable)).exists() + } pub async fn add( &self, appimage: &AppImage, @@ -23,4 +33,10 @@ impl Index { Ok(()) } + pub async fn remove(&self, appname: &str) -> Result<(), Box<dyn std::error::Error>> { + let index_file_path = index_dir().join(format!("{appname}.json")); + fs::remove_file(index_file_path).await?; + + Ok(()) + } } |
