VS-34: refresh plugin catalog at runtime on install/remove #53
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/plugin-catalog-runtime-refresh-vs-34"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements VS-34. Follow-up to VS-33 (#52).
Problem
The plugin catalog was a startup-only snapshot.
PluginCatalogwrapped an immutableArc<Vec<DiscoveredPlugin>>built once at boot (boot.rs:load_plugin_catalog), stored inAppState.plugins, and never rebuilt. The lifecycle handlers only mutated the DB. Two stale-snapshot defects followed (both flagged in the VS-33 review):removeplugindeleted theplugin/<name>doc but left the on-disk files, solist_for_uire-emitted the plugin from the catalog stampedstatus: "installed"until restart.list_for_ui(andGetPluginPermissionList) reportedpermissions: []for it until restart.What changed
PluginCatalognow holdsArc<ArcSwap<CatalogState>>, whereCatalogStatecarries the scanned plugins plus the directory they were scanned from. All clones share oneArcSwap, so a refresh on any handle is visible to every session. Reads (manifests/find/len/is_empty/wasm_path) load the current snapshot lock-free. Public method signatures are unchanged, soboot.rs/main.rsconsumers are untouched.refresh()re-scans the remembered directory and atomically swaps the view (no-op for empty / test catalogs with no directory).remove_on_disk()deletes a plugin's on-disk directory so it cannot reappear from a re-scan. The name is rejected if empty or containing path separators /./.., and the resolved target must stay under the plugins directory.installpluginhandler callsrefresh()on success. Theremovepluginhandler deletes the on-disk directory and callsrefresh()after the DB doc is removed.list_for_ui's disk-onlyinstalledfallback now only fires for genuinely doc-less plugins present on disk at boot, instead of papering over staleness.Acceptance criteria
removeplugin, the nextupdatePluginListno longer lists the plugin (doc deleted and on-disk directory removed)updatePluginListwith its realpermissionswithout a restart (catalog re-scanned on install)GetPluginPermissionListincludes a runtime-installed plugin's permissions without a restart (reads the refreshed catalog)installandremovesucceedTesting
cargo test -p meshcentral-web --lib(433 passed), including 7plugin_catalogtests (4 new:refresh_picks_up_new_pluginasserting a clone sees the refresh,remove_on_disk_then_refresh_drops_plugin,remove_on_disk_rejects_path_escape,refresh_without_dir_is_noop).cargo check -p meshcentral,cargo fmt --check, andcargo clippy -p meshcentral-web --all-targets -- -D warningsall clean.