(
state: &State<'_, AppState>,
app: &tauri::AppHandle,
startup_trace: &State<'_, DesktopStartupTrace>,
trace_step_prefix: &str,
command_name: Option<&str>,
command_started: Ins
| 2106 | } |
| 2107 | |
| 2108 | async fn cleanup_invalid_workspaces_impl( |
| 2109 | state: &State<'_, AppState>, |
| 2110 | app: &tauri::AppHandle, |
| 2111 | startup_trace: &State<'_, DesktopStartupTrace>, |
| 2112 | trace_step_prefix: &str, |
| 2113 | command_name: Option<&str>, |
| 2114 | command_started: Instant, |
| 2115 | ) -> Result<usize, String> { |
| 2116 | let cleanup_started = Instant::now(); |
| 2117 | match state.workspace_service.cleanup_invalid_workspaces().await { |
| 2118 | Ok(local_removed_count) => { |
| 2119 | startup_trace.record_elapsed_step( |
| 2120 | "tauri_command", |
| 2121 | format!("{trace_step_prefix}.local_workspace_cleanup"), |
| 2122 | cleanup_started, |
| 2123 | ); |
| 2124 | let prune_remote_started = Instant::now(); |
| 2125 | let remote_removed_count = prune_unrecoverable_remote_workspaces(state).await; |
| 2126 | startup_trace.record_elapsed_step( |
| 2127 | "tauri_command", |
| 2128 | format!("{trace_step_prefix}.remote_workspace_prune"), |
| 2129 | prune_remote_started, |
| 2130 | ); |
| 2131 | let removed_count = local_removed_count + remote_removed_count; |
| 2132 | |
| 2133 | let apply_context_started = Instant::now(); |
| 2134 | if let Some(workspace_info) = state.workspace_service.get_current_workspace().await { |
| 2135 | apply_active_workspace_context(&state, &app, &workspace_info, None).await; |
| 2136 | } else { |
| 2137 | clear_active_workspace_context(&state, &app, None).await; |
| 2138 | } |
| 2139 | startup_trace.record_elapsed_step( |
| 2140 | "tauri_command", |
| 2141 | format!("{trace_step_prefix}.apply_active_workspace_context"), |
| 2142 | apply_context_started, |
| 2143 | ); |
| 2144 | |
| 2145 | let sync_watchers_started = Instant::now(); |
| 2146 | if let Err(e) = state |
| 2147 | .workspace_identity_watch_service |
| 2148 | .sync_watched_workspaces() |
| 2149 | .await |
| 2150 | { |
| 2151 | warn!( |
| 2152 | "Failed to sync workspace identity watchers after workspace cleanup: {}", |
| 2153 | e |
| 2154 | ); |
| 2155 | } |
| 2156 | startup_trace.record_elapsed_step( |
| 2157 | "tauri_command", |
| 2158 | format!("{trace_step_prefix}.sync_identity_watchers"), |
| 2159 | sync_watchers_started, |
| 2160 | ); |
| 2161 | |
| 2162 | info!( |
| 2163 | "Invalid workspaces cleaned up: removed_count={}", |
| 2164 | removed_count |
| 2165 | ); |
no test coverage detected