mirror of
https://github.com/mihonapp/mihon.git
synced 2026-10-16 13:48:09 -07:00
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
|
||||
|
||||
import app.cash.sqldelight.async.coroutines.awaitAsList
|
||||
import app.cash.sqldelight.async.coroutines.awaitAsOne
|
||||
import dev.zacsweers.metro.AppScope
|
||||
import dev.zacsweers.metro.ContributesBinding
|
||||
import dev.zacsweers.metro.Inject
|
||||
@@ -49,6 +50,9 @@ class ExtensionStoreRepositoryImpl(
|
||||
service.fetch(store.index_url)
|
||||
.mapCatching {
|
||||
database.transaction {
|
||||
if (!database.extension_storeQueries.contains(store.index_url).awaitAsOne()) {
|
||||
return@transaction
|
||||
}
|
||||
upsert(it)
|
||||
if (store.index_url != it.indexUrl) {
|
||||
database.extension_storeQueries.delete(store.index_url)
|
||||
|
||||
@@ -11,10 +11,8 @@ CREATE TABLE extension_store(
|
||||
extension_list_url TEXT
|
||||
);
|
||||
|
||||
get:
|
||||
SELECT *
|
||||
FROM extension_store
|
||||
WHERE index_url = :indexUrl;
|
||||
contains:
|
||||
SELECT EXISTS(SELECT 0 FROM extension_store WHERE index_url = :indexUrl);
|
||||
|
||||
getAll:
|
||||
SELECT *
|
||||
|
||||
Reference in New Issue
Block a user