Skip to content

Commit a700c7a

Browse files
committed
fix(provider): fix incorrect download path for local updates
1 parent ab5187c commit a700c7a

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

data/provider/src/main/kotlin/com/flixclusive/data/provider/ProviderManager.kt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,15 @@ class ProviderManager @Inject constructor(
260260

261261
suspend fun loadProvider(
262262
providerData: ProviderData,
263-
needsDownload: Boolean = false
263+
needsDownload: Boolean = false,
264+
filePath: String? = null
264265
) {
265266
check(providerData.repositoryUrl != null) {
266267
"Repository URL must not be null if using this overloaded method."
267268
}
268269

269-
val file = context.provideValidProviderPath(providerData)
270+
val file = filePath?.let { File(it) }
271+
?: context.provideValidProviderPath(providerData)
270272

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

@@ -525,14 +527,17 @@ class ProviderManager @Inject constructor(
525527
newProviderData,
526528
localPrefix = localPrefix
527529
)
530+
val newPreference = oldPreference.copy(
531+
name = newProviderData.name,
532+
filePath = newPath.absolutePath
533+
)
528534

529535
loadProviderOnSettings(
530-
provider = oldPreference.copy(
531-
name = newProviderData.name,
532-
filePath = newPath.absolutePath
533-
),
536+
provider = newPreference,
534537
index = oldOrderPosition
535538
)
539+
540+
return newPreference
536541
}
537542

538543
suspend fun reloadProvider(
@@ -547,13 +552,14 @@ class ProviderManager @Inject constructor(
547552
unloadOnSettings = false
548553
)
549554

550-
reloadProviderOnSettings(
555+
val newProviderPreference = reloadProviderOnSettings(
551556
oldProviderData = oldProviderData,
552557
newProviderData = newProviderData
553558
)
554559

555560
loadProvider(
556561
providerData = newProviderData,
562+
filePath = newProviderPreference.filePath,
557563
needsDownload = true
558564
)
559565
}

0 commit comments

Comments
 (0)