mirror of
https://github.com/openai/codex.git
synced 2026-11-03 19:53:25 +00:00
fix(plugins): clean inactive versions on startup
This commit is contained in:
@@ -1487,6 +1487,7 @@ impl PluginsManager {
|
||||
on_effective_plugins_changed: Option<Arc<dyn Fn() + Send + Sync + 'static>>,
|
||||
) {
|
||||
if config.plugins_enabled {
|
||||
self.cleanup_inactive_plugin_versions_for_config(config);
|
||||
self.start_curated_repo_sync();
|
||||
let should_spawn_marketplace_auto_upgrade = {
|
||||
let mut state = match self.configured_marketplace_upgrade_state.write() {
|
||||
|
||||
@@ -3198,6 +3198,51 @@ fn refresh_curated_plugin_cache_installs_short_sha_version_alongside_existing_lo
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn cleanup_inactive_plugin_versions_for_config_removes_configured_inactive_versions() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
write_file(
|
||||
&tmp.path().join(CONFIG_TOML_FILE),
|
||||
r#"[features]
|
||||
plugins = true
|
||||
|
||||
[plugins."slack@openai-curated"]
|
||||
enabled = true
|
||||
"#,
|
||||
);
|
||||
write_plugin(
|
||||
&tmp.path().join("plugins/cache/openai-curated"),
|
||||
"slack/1.0.0",
|
||||
"slack",
|
||||
);
|
||||
write_plugin(
|
||||
&tmp.path().join("plugins/cache/openai-curated"),
|
||||
"slack/2.0.0",
|
||||
"slack",
|
||||
);
|
||||
fs::write(
|
||||
tmp.path()
|
||||
.join("plugins/cache/openai-curated/slack/.active-version"),
|
||||
"2.0.0\n",
|
||||
)
|
||||
.unwrap();
|
||||
let config = load_config(tmp.path(), tmp.path()).await;
|
||||
|
||||
PluginsManager::new(tmp.path().to_path_buf())
|
||||
.cleanup_inactive_plugin_versions_for_config(&config);
|
||||
|
||||
assert!(
|
||||
!tmp.path()
|
||||
.join("plugins/cache/openai-curated/slack/1.0.0")
|
||||
.exists()
|
||||
);
|
||||
assert!(
|
||||
tmp.path()
|
||||
.join("plugins/cache/openai-curated/slack/2.0.0")
|
||||
.is_dir()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn refresh_curated_plugin_cache_reinstalls_missing_configured_plugin_with_current_short_version() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -339,9 +339,6 @@ impl Session {
|
||||
std::mem::replace(&mut *manager, refreshed_manager)
|
||||
};
|
||||
old_manager.shutdown().await;
|
||||
self.services
|
||||
.plugins_manager
|
||||
.cleanup_inactive_plugin_versions_for_config(&config.plugins_config_input());
|
||||
}
|
||||
|
||||
pub(crate) async fn refresh_mcp_servers_if_requested(
|
||||
|
||||
Reference in New Issue
Block a user