Offline collection volume loses deletion retry information
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start with ProfileManager.deleteProfile and the collection path helpers it uses, then inspect ProfileManagerTest.kt, especially the offline volume regression test described in this issue. Check how deletion failures affect profile settings and whether a retry can complete cleanup after the volume is mounted again. Done when the profile and its collection data are both removed after a failed offline deletion is retried.
Written by the indexing model from the issue text.
Description
Assisted-by: GPT-6.1-Sol xhigh & GPT-6-Astra xhigh
[EXISTING] Offline collection volume loses deletion retry information
Subject: [EXISTING] Offline collection volume loses deletion retry information
Deleting a profile while its collection volume is unmounted removes the profile settings and leaves its cards, media, and backups behind.
⚠️ This issue existed before the PR and should likely be split off into a separate issue.
The new delete action exposes the pre-existing helper defect.
---
diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/multiprofile/ProfileManagerTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/multiprofile/ProfileManagerTest.kt
index 6492405d73..e44a464313 100644
--- a/AnkiDroid/src/test/java/com/ichi2/anki/multiprofile/ProfileManagerTest.kt
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/multiprofile/ProfileManagerTest.kt
@@ -1187,6 +1187,44 @@ class ProfileManagerTest {
}
}
+ @Test
+ fun `an offline collection volume keeps settings until it can be deleted`() {
+ val manager = ProfileManager.create(context)
+ val work = manager.createNewProfile(ProfileName.fromTrustedSource("Work"))
+ val mount = File(appDataRoot, "removable_card").apply { mkdirs() }
+ val detached = File(appDataRoot, "detached_card")
+ val collectionDir = File(mount, "AnkiDroid").apply { mkdirs() }
+ val collection = File(collectionDir, "collection.anki2").apply { writeText("collection") }
+ val media = File(collectionDir, "collection.media/image.jpg").apply {
+ parentFile!!.mkdirs()
+ writeText("media")
+ }
+ writeProfileCollectionPath(work, collectionDir)
+ val settings = File(appDataRoot, "shared_prefs/profile_${work.value}_${context.packageName}_preferences.xml")
+ ShadowEnvironment.setExternalStorageRemovable(mount, true)
+ ShadowEnvironment.setExternalStorageState(mount, Environment.MEDIA_MOUNTED)
+ assertTrue(mount.renameTo(detached))
+ ShadowEnvironment.setExternalStorageState(mount, Environment.MEDIA_UNMOUNTED)
+ try {
+ assertEquals(Environment.MEDIA_UNMOUNTED, Environment.getExternalStorageState(collectionDir))
+ assertFalse(collectionDir.exists())
+
+ assertThrows(IOException::class.java) { manager.deleteProfile(work) }
+
+ assertTrue(manager.getAllProfiles().containsKey(work))
+ assertTrue(settings.exists())
+ } finally {
+ assertTrue(detached.renameTo(mount))
+ ShadowEnvironment.setExternalStorageState(mount, Environment.MEDIA_MOUNTED)
+ }
+
+ manager.deleteProfile(work)
+
+ assertFalse(collection.exists())
+ assertFalse(media.exists())
+ assertFalse(manager.getAllProfiles().containsKey(work))
+ }
+
/** Stubs [CookieManager.getInstance]. [completesRemoval] fires the cookie removal callback. */
private class RecordingEditor(
private val delegate: SharedPreferences.Editor,
Originally posted by @david-allison in https://github.com/ankidroid/Anki-Android/pull/23329#pullrequestreview-5926332571
- Dominant language
- Kotlin
- Stars
- 12.3k
- Forks
- 3.1k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 383
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ankidroid/Anki-Android
-
Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ankidroid/Anki-Android#23392 ·
Maintainers usually reply within 1 day
-
Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ankidroid/Anki-Android#23390 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
ankidroid/Anki-Android#23385 · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
ankidroid/Anki-Android#23374 ·
Maintainers usually reply within 1 day
-
Selected custom-study tags become unreadablePossibly taken @chesh-ire claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ankidroid/Anki-Android#23352 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
All issues in ankidroid/Anki-Android
Similar issues
-
Bug Domain changed
Difficulty 1/5 Under an hour Newbie friendliness 79/100
keiyoushi/extensions-source#21174 ·
Maintainers usually reply within 1 day
-
Unified account interface not translated into Simplified ChinesePossibly taken @xuenhua claimed this 3 days ago. Openunconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
thunderbird/thunderbird-android#11936 · 1 comment ·
Maintainers usually reply within 3 days
-
Update toast stylingOpendesign good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
scribe-org/Scribe-Android#778 ·
Maintainers usually reply within 1 day
-
AI Generated CI/CD ⚒️ Flaky-tests 🐦 go 🏃
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
valkey-io/valkey-glide#7772 ·
Maintainers usually reply within 1 day
-
Error Handling Swift
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Automattic/wordpress-rs#1759 ·
Maintainers usually reply within 1 day