Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: separate same-name extension's installing status from different repos #295

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,12 @@ class ExtensionManager(
}

fun cancelInstallUpdateExtension(extension: Extension) {
installer.cancelInstall(extension.pkgName)
installer.cancelInstall(
extension.pkgName +
// KMK -->
":${extension.signatureHash}",
// KMK <--
)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ internal class ExtensionInstaller(private val context: Context) {
* @param extension The extension to install.
*/
fun downloadAndInstall(url: String, extension: Extension): Flow<InstallStep> {
val pkgName = extension.pkgName
val pkgName = extension.pkgName +
// KMK -->
":${extension.signatureHash}"
// KMK <--

val oldDownload = activeDownloads[pkgName]
if (oldDownload != null) {
Expand Down Expand Up @@ -236,7 +239,7 @@ internal class ExtensionInstaller(private val context: Context) {
/**
* Deletes the download for the given package name.
*
* @param pkgName The package name of the download to delete.
* @param pkgName The package name of the download to delete together with its signature.
*/
private fun deleteDownload(pkgName: String) {
val downloadId = activeDownloads.remove(pkgName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@ class ExtensionsScreenModel(
val context = Injekt.get<Application>()
val extensionMapper: (Map<String, InstallStep>) -> ((Extension) -> ExtensionUiModel.Item) = { map ->
{
ExtensionUiModel.Item(it, map[it.pkgName] ?: InstallStep.Idle)
ExtensionUiModel.Item(
it,
map[
it.pkgName +
// KMK -->
":${it.signatureHash}",
// KMK <--
] ?: InstallStep.Idle,
)
}
}
val queryFilter: (String) -> ((Extension) -> Boolean) = { query ->
Expand Down Expand Up @@ -193,11 +201,26 @@ class ExtensionsScreenModel(
}

private fun addDownloadState(extension: Extension, installStep: InstallStep) {
currentDownloads.update { it + Pair(extension.pkgName, installStep) }
currentDownloads.update {
it + Pair(
extension.pkgName +
// KMK -->
":${extension.signatureHash}",
// KMK <--
installStep,
)
}
}

private fun removeDownloadState(extension: Extension) {
currentDownloads.update { it - extension.pkgName }
currentDownloads.update {
it - (
extension.pkgName +
// KMK -->
":${extension.signatureHash}"
// KMK <--
)
}
}

private suspend fun Flow<InstallStep>.collectToInstallUpdate(extension: Extension) =
Expand Down
Loading