Add command to delete local repositories

TG-25

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent a713c20aa4
commit 8218ae3235

@ -81,6 +81,29 @@ pub async fn remove_repository(app_state: AppAccess<'_>, name: String) -> Plugin
}
}
#[tauri::command]
pub async fn delete_repository(app_state: AppAccess<'_>, name: String) -> PluginResult<()> {
let settings = app_state.settings.read().await;
if let Some(repository) = settings.repositories.get(&name) {
if let Some(path) = &repository.path {
fs::remove_dir_all(PathBuf::from(path)).await?;
Ok(())
} else {
Err(PluginError::from(format!(
"The repository '{}' is a remote repository",
name
)))
}
} else {
Err(PluginError::from(format!(
"The repository '{}' does not exist.",
name
)))
}
}
#[tauri::command]
pub async fn check_local_repository_exists(path: String) -> PluginResult<bool> {
let config_path = PathBuf::from(path).join(REPO_CONFIG_FILE);

@ -57,7 +57,8 @@ impl<R: Runtime> MediarepoPlugin<R> {
add_local_file,
save_file_locally,
delete_thumbnails,
read_file
read_file,
delete_repository
]),
}
}

Loading…
Cancel
Save