ProfileStorageDeletion.kt
composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/app/profiles/ProfileStorageDeletion.kt
1package eu.friedcutlet.yokan.app.profiles23import eu.friedcutlet.yokan.domain.ProfileId45/** Call only under the coordinator's deletion lease, after all sessions/work for this ID retire. */6internal suspend fun deleteProfileStorage(id: ProfileId, exportedBackups: List<String> = emptyList()) {7 require(id != ProfileId.Default) { "Default storage cannot be deleted" }8 val lease = acquireProfileStorageLease(id)9 try { deletePlatformProfileStorage(id, exportedBackups) }10 finally { kotlinx.coroutines.withContext(kotlinx.coroutines.NonCancellable) { lease.close() } }11}1213/** Uses app-owned roots, never settings paths or external-folder grants. */14internal expect suspend fun deletePlatformProfileStorage(id: ProfileId, exportedBackups: List<String>)15