summaryrefslogtreecommitdiff
path: root/src/index.rs
diff options
context:
space:
mode:
authorNaz <ndpm13@ch-naseem.com>2025-07-31 15:59:56 +0100
committerNaz <ndpm13@ch-naseem.com>2025-07-31 15:59:56 +0100
commit180fe06facf1f8b4796df69a42596643990b9d32 (patch)
treee4fc09be4c29c01a1f62e988a19e99d1c3a7a85e /src/index.rs
parent030eef4c9b4f82fe16ddd019c436e7065758d3dc (diff)
✨feat: remove expect from path module
Diffstat (limited to 'src/index.rs')
-rw-r--r--src/index.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/index.rs b/src/index.rs
index dff2f58..8f2521a 100644
--- a/src/index.rs
+++ b/src/index.rs
@@ -10,19 +10,19 @@ impl Index {
Self {}
}
pub async fn get(&self, appname: &str) -> Result<AppImage> {
- let index_file_path = index_dir().join(format!("{appname}.json"));
+ 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 fn exists(&self, executable: &str) -> Result<bool> {
+ Ok(index_dir()?.join(format!("{}.json", &executable)).exists())
}
pub async fn add(&self, appimage: &AppImage, appname: &str) -> Result<()> {
- fs::create_dir_all(&index_dir()).await?;
+ fs::create_dir_all(&index_dir()?).await?;
- let index_file = &index_dir().join(format!("{appname}.json"));
+ let index_file = &index_dir()?.join(format!("{appname}.json"));
let json = serde_json::to_string_pretty(appimage)?;
fs::write(index_file, json).await?;
@@ -30,7 +30,7 @@ impl Index {
Ok(())
}
pub async fn remove(&self, appname: &str) -> Result<()> {
- let index_file_path = index_dir().join(format!("{appname}.json"));
+ let index_file_path = index_dir()?.join(format!("{appname}.json"));
fs::remove_file(index_file_path).await?;
Ok(())