|
|
@ -65,6 +65,32 @@ pub async fn add_repository(
|
|
|
|
Ok(repositories)
|
|
|
|
Ok(repositories)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[tauri::command]
|
|
|
|
|
|
|
|
pub async fn remove_repository(app_state: AppAccess<'_>, name: String) -> PluginResult<()> {
|
|
|
|
|
|
|
|
let mut settings = app_state.settings.write().await;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if let Some(_repo) = settings.repositories.remove(&name) {
|
|
|
|
|
|
|
|
save_settings(&settings)?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
|
|
} 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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !config_path.exists() {
|
|
|
|
|
|
|
|
Ok(false)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Ok(true)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[tauri::command]
|
|
|
|
#[tauri::command]
|
|
|
|
pub async fn disconnect_repository(
|
|
|
|
pub async fn disconnect_repository(
|
|
|
|
app_state: AppAccess<'_>,
|
|
|
|
app_state: AppAccess<'_>,
|
|
|
@ -104,15 +130,7 @@ pub async fn select_repository(
|
|
|
|
.ok_or(PluginError::from(
|
|
|
|
.ok_or(PluginError::from(
|
|
|
|
format!("Repository '{}' not found", name).as_str(),
|
|
|
|
format!("Repository '{}' not found", name).as_str(),
|
|
|
|
))?;
|
|
|
|
))?;
|
|
|
|
if let Some(path) = app_state
|
|
|
|
close_selected_repository(&app_state).await?;
|
|
|
|
.active_repo
|
|
|
|
|
|
|
|
.read()
|
|
|
|
|
|
|
|
.await
|
|
|
|
|
|
|
|
.clone()
|
|
|
|
|
|
|
|
.and_then(|r| r.path)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
app_state.stop_running_daemon(&path).await?;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
let address = if let Some(address) = &repo.address {
|
|
|
|
let address = if let Some(address) = &repo.address {
|
|
|
|
address.clone()
|
|
|
|
address.clone()
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -142,6 +160,20 @@ pub async fn select_repository(
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async fn close_selected_repository(app_state: &AppAccess<'_>) -> PluginResult<()> {
|
|
|
|
|
|
|
|
if let Some(path) = app_state
|
|
|
|
|
|
|
|
.active_repo
|
|
|
|
|
|
|
|
.read()
|
|
|
|
|
|
|
|
.await
|
|
|
|
|
|
|
|
.clone()
|
|
|
|
|
|
|
|
.and_then(|r| r.path)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
app_state.stop_running_daemon(&path).await?;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn read_repo_config(path: PathBuf) -> PluginResult<RepoConfig> {
|
|
|
|
async fn read_repo_config(path: PathBuf) -> PluginResult<RepoConfig> {
|
|
|
|
let toml_str = fs::read_to_string(path).await?;
|
|
|
|
let toml_str = fs::read_to_string(path).await?;
|
|
|
|
let config = toml::from_str(&toml_str)?;
|
|
|
|
let config = toml::from_str(&toml_str)?;
|
|
|
|