Skip to content

Comments

Implement database-driven provider uninstallation#36

Open
Quickkill0 wants to merge 2 commits intomaxpiva:mainfrom
Quickkill0:fix/provider-uninstallation-v2
Open

Implement database-driven provider uninstallation#36
Quickkill0 wants to merge 2 commits intomaxpiva:mainfrom
Quickkill0:fix/provider-uninstallation-v2

Conversation

@Quickkill0
Copy link
Contributor

Summary

Addresses #28 and implements the approach outlined by @maxpiva in PR #34 review.

Core fix: ReconcileLocalAsync was resurrecting uninstalled providers by setting IsEnabled = true when a previously dead provider reappeared. This made uninstallation ineffective.

What changed

  • ProviderStorageEntity — Added [NotMapped] IsActive property (IsEnabled && !IsBroken && !IsDead) so all three state flags are checked consistently
  • ReconcileLocalAsync — Never sets IsEnabled = true automatically. Dead flag is cleared when a provider reappears, but the user must explicitly re-install. Only marks providers as IsDead if they were IsEnabled (skips already-uninstalled ones)
  • DisableProviderAsync — Full uninstall: sets IsEnabled = false, marks related SeriesProviderEntity.IsUninstalled = true, removes from Mihon bridge, refreshes cache. Does not delete from DB (series may still reference them)
  • InstallProviderAsync / InstallProviderFromFileAsync — On install, re-enables existing providers (IsEnabled = true, clears IsDead/IsBroken) and restores SeriesProviderEntity.IsUninstalled = false via shared ReEnableProvidersForPackageAsync helper
  • IsEnabledIsActive auditGetSourcesForLanguagesAsync, language list building, CheckAndScheduleJobsAsync, and UpdateExtensionJobsAsync now use IsActive to exclude broken/dead providers. RefreshCacheAsync second pass keeps IsEnabled (user intent for recovery)

Design decisions per @maxpiva's feedback

Requirement Implementation
DB is single source of truth IsEnabled is the install/uninstall flag, bridge state is secondary
ReconcileLocalAsync never auto-enables ✅ Removed p.IsEnabled = true from dead-provider recovery
Check IsBroken/IsDead alongside IsEnabled IsActive property used in all usability checks
Never delete providers from DB ✅ Soft-disable only (IsEnabled = false)
Uninstall → SeriesProvider.IsUninstalled = true
Install → SeriesProvider.IsUninstalled = false

Test plan

  • Uninstall a provider → verify IsEnabled = false in DB, SeriesProvider.IsUninstalled = true, extension removed from bridge
  • Verify uninstalled provider does not reappear after cache refresh / reconcile
  • Re-install same provider → verify IsEnabled = true, SeriesProvider.IsUninstalled = false
  • Mark a provider as broken/dead → verify it's excluded from queries, language lists, and job scheduling
  • Verify no series data is lost after uninstall (DB entries preserved)

Fix provider uninstallation by making the database the single source of
truth for provider state, addressing the core issue where
ReconcileLocalAsync was resurrecting uninstalled providers.

Changes:
- ReconcileLocalAsync no longer sets IsEnabled=true automatically
- DisableProviderAsync now marks SeriesProvider entries as IsUninstalled,
  removes from Mihon bridge, and preserves DB entries (no delete)
- InstallProviderAsync restores SeriesProvider.IsUninstalled=false
- Add IsActive computed property (IsEnabled && !IsBroken && !IsDead)
- Replace IsEnabled-only checks with IsActive where provider usability
  matters (queries, job scheduling, language lists)

Fix maxpiva#28
Refactor dead provider handling logic to simplify conditions for marking providers as dead and managing their enabled state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants