Don't bring back extension stores removed during a refresh
A store's refreshed details are written only if the store still exists when its fetch returns, so one removed while its index was loading stays removed. The unused get query becomes contains.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package mihon.data.extension.repository
|
package mihon.data.extension.repository
|
||||||
|
|
||||||
import app.cash.sqldelight.async.coroutines.awaitAsList
|
import app.cash.sqldelight.async.coroutines.awaitAsList
|
||||||
|
import app.cash.sqldelight.async.coroutines.awaitAsOne
|
||||||
import dev.zacsweers.metro.AppScope
|
import dev.zacsweers.metro.AppScope
|
||||||
import dev.zacsweers.metro.ContributesBinding
|
import dev.zacsweers.metro.ContributesBinding
|
||||||
import dev.zacsweers.metro.Inject
|
import dev.zacsweers.metro.Inject
|
||||||
@@ -49,6 +50,9 @@ class ExtensionStoreRepositoryImpl(
|
|||||||
service.fetch(store.index_url)
|
service.fetch(store.index_url)
|
||||||
.mapCatching {
|
.mapCatching {
|
||||||
database.transaction {
|
database.transaction {
|
||||||
|
if (!database.extension_storeQueries.contains(store.index_url).awaitAsOne()) {
|
||||||
|
return@transaction
|
||||||
|
}
|
||||||
upsert(it)
|
upsert(it)
|
||||||
if (store.index_url != it.indexUrl) {
|
if (store.index_url != it.indexUrl) {
|
||||||
database.extension_storeQueries.delete(store.index_url)
|
database.extension_storeQueries.delete(store.index_url)
|
||||||
|
|||||||
@@ -11,10 +11,8 @@ CREATE TABLE extension_store(
|
|||||||
extension_list_url TEXT
|
extension_list_url TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
get:
|
contains:
|
||||||
SELECT *
|
SELECT EXISTS(SELECT 0 FROM extension_store WHERE index_url = :indexUrl);
|
||||||
FROM extension_store
|
|
||||||
WHERE index_url = :indexUrl;
|
|
||||||
|
|
||||||
getAll:
|
getAll:
|
||||||
SELECT *
|
SELECT *
|
||||||
|
|||||||
Reference in New Issue
Block a user