Skip to content

Commit

Permalink
fix(provider): fix incorrect download path for local updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rhenwinch committed Nov 8, 2024
1 parent ab5187c commit a700c7a
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,15 @@ class ProviderManager @Inject constructor(

suspend fun loadProvider(
providerData: ProviderData,
needsDownload: Boolean = false
needsDownload: Boolean = false,
filePath: String? = null
) {
check(providerData.repositoryUrl != null) {
"Repository URL must not be null if using this overloaded method."
}

val file = context.provideValidProviderPath(providerData)
val file = filePath?.let { File(it) }
?: context.provideValidProviderPath(providerData)

if (needsDownload && !downloadProvider(file, providerData.buildUrl!!)) {
throw IOException("Something went wrong trying to download the provider.")
Expand Down Expand Up @@ -516,7 +518,7 @@ class ProviderManager @Inject constructor(
private suspend fun reloadProviderOnSettings(
oldProviderData: ProviderData,
newProviderData: ProviderData
) {
): ProviderPreference {
val oldOrderPosition = getPositionIndexFromSettings(oldProviderData.name)
val oldPreference = appSettingsManager.cachedProviderSettings.providers[oldOrderPosition]

Expand All @@ -525,14 +527,17 @@ class ProviderManager @Inject constructor(
newProviderData,
localPrefix = localPrefix
)
val newPreference = oldPreference.copy(
name = newProviderData.name,
filePath = newPath.absolutePath
)

loadProviderOnSettings(
provider = oldPreference.copy(
name = newProviderData.name,
filePath = newPath.absolutePath
),
provider = newPreference,
index = oldOrderPosition
)

return newPreference
}

suspend fun reloadProvider(
Expand All @@ -547,13 +552,14 @@ class ProviderManager @Inject constructor(
unloadOnSettings = false
)

reloadProviderOnSettings(
val newProviderPreference = reloadProviderOnSettings(
oldProviderData = oldProviderData,
newProviderData = newProviderData
)

loadProvider(
providerData = newProviderData,
filePath = newProviderPreference.filePath,
needsDownload = true
)
}
Expand Down

0 comments on commit a700c7a

Please sign in to comment.