It listed every container on the daemon — including the user's unrelated postgres, mysql and other work — and handed the summaries to the webview. It had a registration, a command, a docker-layer helper, a typed frontend wrapper and a `SiblingContainer` type, and zero call sites. An audit named it as step one of an escalation chain: enumerate the daemon's containers, then point `update_project`'s unvalidated `container_id` at one and read its files through the file-command surface. The second half of that chain is closed now, but a command that exposes the user's unrelated containers and serves no feature is surface with no upside. Found by the registration test added in the previous commit, which is the answer to "why test something the compiler already checks": the compiler is perfectly happy with a command nobody calls. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GBq2rGum6GX7xXgsas1fDc
40 lines
1.1 KiB
Rust
40 lines
1.1 KiB
Rust
use tauri::State;
|
|
|
|
use crate::docker;
|
|
use crate::models::{container_config, ContainerInfo};
|
|
use crate::AppState;
|
|
|
|
#[tauri::command]
|
|
pub async fn check_docker() -> Result<bool, String> {
|
|
docker::check_docker_available().await
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn check_image_exists(state: State<'_, AppState>) -> Result<bool, String> {
|
|
let settings = state.settings_store.get();
|
|
let image_name = container_config::resolve_image_name(&settings.image_source, &settings.custom_image_name);
|
|
docker::image_exists(&image_name).await
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn build_image(app_handle: tauri::AppHandle) -> Result<(), String> {
|
|
use tauri::Emitter;
|
|
docker::build_image(move |msg| {
|
|
let _ = app_handle.emit("image-build-progress", msg);
|
|
})
|
|
.await
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn get_container_info(
|
|
project_id: String,
|
|
state: State<'_, AppState>,
|
|
) -> Result<Option<ContainerInfo>, String> {
|
|
let project = state
|
|
.projects_store
|
|
.get(&project_id)
|
|
.ok_or_else(|| format!("Project {} not found", project_id))?;
|
|
docker::get_container_info(&project).await
|
|
}
|
|
|