Skip to content

Commit d14dc83

Browse files
committed
fix(migration): sequence-guard stale encryption check in preview
A stale preview job suspended in the isEncryptedExport check can resume after a newer preview has started (job cancellation is cooperative). Its success branch updated the password prompt without a sequence check, so it could redirect the UI to the wrong import URI. Apply the same sequence guard used by the failure and post-preview paths.
1 parent 4f1a822 commit d14dc83

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

app/src/main/java/network/columba/app/viewmodel/MigrationViewModel.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,11 @@ class MigrationViewModel
234234
val encryptedResult = migrationImporter.isEncryptedExport(uri)
235235
return encryptedResult.fold(
236236
onSuccess = { isEncrypted ->
237-
if (isEncrypted) {
237+
if (sequence != importSequence) {
238+
// A newer preview superseded this one; do not update
239+
// state (e.g. a stale password prompt for the old URI).
240+
false
241+
} else if (isEncrypted) {
238242
Log.i(TAG, "File is encrypted, requesting password")
239243
_pendingImportUri.value = uri
240244
_uiState.value = MigrationUiState.PasswordRequired(uri)

0 commit comments

Comments
 (0)