Skip to content

Commit

Permalink
fix: local debugging providers are not properly loaded.
Browse files Browse the repository at this point in the history
  • Loading branch information
rhenwinch committed May 25, 2024
1 parent be130a2 commit b8e01f7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/util/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
<string name="count_selection_format">%1$d selected</string>

<!-- State messages -->
<string name="all_providers_installed">All providers has been installed!</string>
<string name="all_providers_installed">All providers have been installed!</string>
<string name="checking_for_updates">Checking for updates…</string>
<string name="copied_link">Link has been copied</string>
<string name="copy_stack_trace_message">You could open a github issue and paste this stack trace.</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,11 @@ class ProviderManager @Inject constructor(
= providerSettings.providers.any {
it.filePath == providerFile.absolutePath
}.not()
val isNotUpdaterJsonFile
= !providerFile.name
.equals("updater.json", true)

if (isProviderNotYetLoaded) {
if (isProviderNotYetLoaded && isNotUpdaterJsonFile) {
appSettingsManager.updateProviderSettings {
it.copy(
providers =
Expand Down Expand Up @@ -179,7 +182,7 @@ class ProviderManager @Inject constructor(
val providerData = updaterJsonList.find { it.name.plus(".flx").equals(providerName, true) }

if (providerData == null) {
errorLog("Provider cannot be found on the updater.json file!")
errorLog("Provider [$providerName] cannot be found on the updater.json file!")
return
}

Expand Down Expand Up @@ -352,9 +355,12 @@ class ProviderManager @Inject constructor(
val provider = providers[providerData.name]
val file = context.provideValidProviderPath(providerData)

if (provider != null && file.exists()) {
unloadProvider(provider, file)
if (provider == null || !file.exists()) {
errorLog("Provider [${providerData.name}] not found. Cannot be unloaded")
return
}

unloadProvider(provider, file)
}

/**
Expand All @@ -367,9 +373,12 @@ class ProviderManager @Inject constructor(
val provider = providers[providerPreference.name]
val file = File(providerPreference.filePath)

if (provider != null && file.exists()) {
unloadProvider(provider, file)
if (provider == null || !file.exists()) {
errorLog("Provider [${providerPreference.name}] not found. Cannot be unloaded")
return
}

unloadProvider(provider, file)
}

private suspend fun unloadProvider(
Expand Down

0 comments on commit b8e01f7

Please sign in to comment.