Subscriptions are added back again by migration
Closed this issue · 4 comments
When removing a subscription, it's only removed from the database. When the synchronization runs, the worker sees the calendar on the system, but not the entry in the database, and it considers it as "an old calendar", and migrates it.
This is even worse, since in the conversion from subscription to calendar properties, we don't add NAME
:
icsx5/app/src/main/java/at/bitfire/icsdroid/db/entity/Subscription.kt
Lines 75 to 85 in 34ab68d
So the system doesn't know the url of the subscription, and just adds them with https://invalid-url
as specified here:
icsx5/app/src/main/java/at/bitfire/icsdroid/db/entity/Subscription.kt
Lines 61 to 63 in 34ab68d
We should fix the Subscription
-> ContentValues
conversion with this:
/**
* Converts this subscription's properties to [android.content.ContentValues] that can be
* passed to the calendar provider in order to create/update the local calendar.
*/
fun toCalendarProperties() = contentValuesOf(
Calendars._ID to id,
Calendars.NAME to url.toString(),
Calendars.CALENDAR_DISPLAY_NAME to displayName,
Calendars.CALENDAR_COLOR to color,
Calendars.CALENDAR_ACCESS_LEVEL to Calendars.CAL_ACCESS_READ,
Calendars.SYNC_EVENTS to 1
)
Which is fixed here: 3a84525
For migration, I suggest simply removing this process from synchronization, and moving it to the callback on the database creation:
icsx5/app/src/main/java/at/bitfire/icsdroid/db/AppDatabase.kt
Lines 61 to 66 in 34ab68d
Since I think there are really no reasons to run migration again after the database has been created. This also gets rid of ONLY_MIGRATE
from the worker, which is a bit specific.
Depends on #133
This PR/issue depends on: * #133
This PR/issue depends on: * #133
This PR/issue depends on: * #133