MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / _unmanage_dropped_slugs

Function _unmanage_dropped_slugs

apps/plugins/api_views.py:365–386  ·  view source on GitHub ↗

After a manifest refresh, clear source_repo on any installed plugins whose slug is no longer listed in the repo's manifest. Also syncs the 'deprecated' flag for all plugins that remain managed by this repo.

(repo, new_manifest_data)

Source from the content-addressed store, hash-verified

363
364
365def _unmanage_dropped_slugs(repo, new_manifest_data):
366 """After a manifest refresh, clear source_repo on any installed plugins
367 whose slug is no longer listed in the repo's manifest. Also syncs the
368 'deprecated' flag for all plugins that remain managed by this repo."""
369 manifest = new_manifest_data.get("manifest", new_manifest_data)
370 plugin_entries = {p["slug"]: p for p in manifest.get("plugins", []) if p.get("slug")}
371 current_slugs = set(plugin_entries.keys())
372
373 dropped = PluginConfig.objects.filter(source_repo=repo).exclude(slug__in=current_slugs)
374 count = dropped.update(source_repo=None, slug="", deprecated=False)
375 if count:
376 logger.info(
377 "Unmanaged %d plugin(s) removed from repo '%s' manifest",
378 count, repo.name,
379 )
380
381 # Sync deprecated flag for retained managed plugins
382 for cfg in PluginConfig.objects.filter(source_repo=repo, slug__in=current_slugs):
383 new_deprecated = bool(plugin_entries.get(cfg.slug, {}).get("deprecated", False))
384 if cfg.deprecated != new_deprecated:
385 cfg.deprecated = new_deprecated
386 cfg.save(update_fields=["deprecated", "updated_at"])
387
388
389class PluginImportAPIView(PluginAuthMixin, APIView):

Callers 2

refresh_plugin_reposFunction · 0.85
postMethod · 0.85

Calls 5

keysMethod · 0.80
getMethod · 0.45
filterMethod · 0.45
updateMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected