Skip to content
Snippets Groups Projects
Unverified Commit 30dd298f authored by GyDi's avatar GyDi
Browse files

feat: delete file

parent 0ff8bb80
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
use serde_yaml::{Mapping, Value};
use std::collections::HashMap;
use std::env::temp_dir;
use std::fs::File;
use std::fs::{remove_file, File};
use std::io::Write;
use std::path::PathBuf;
use std::time::{SystemTime, UNIX_EPOCH};
......@@ -249,7 +249,18 @@ rules:\n\n
return Err("index out of bound".into());
}
items.remove(index);
let mut rm_item = items.remove(index);
// delete the file
if let Some(file) = rm_item.file.take() {
let file_path = dirs::app_home_dir().join("profiles").join(file);
if file_path.exists() {
if let Err(err) = remove_file(file_path) {
log::error!("{err}");
}
}
}
let mut should_change = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment