Commit Graph

63 Commits

Author SHA1 Message Date
Torsten Grote
dea8a2e504 [db] track and clear repo update errors
Historically, we've just shown a giant Toast for repo update errors, now we track them in the DB, so we can properly expose them in the UI.
2026-01-05 17:24:10 -03:00
Torsten Grote
88f817e5ca [db] allow providing PackageInfo maps to avoid hammering PackageManager
The app may maintain PackageInfo for apps already, so there's no need to keep asking the system for it. We could instead just work with what we already have.

Also, we discovered that chunking the package names isn't needed for newer Android versions. This is only relevant for whom has more than 999 apps installed.
2025-12-29 11:23:59 -03:00
Torsten Grote
5ab649f14d [db] optimize adding repos
We now hang on to the index file while streaming it for repo preview purposes. This avoids having to re-download that file and we can properly add the repo right away.

This then allows us to bring the user to the list of apps in that repository without it being initially empty.
2025-11-04 08:50:53 -03:00
Torsten Grote
3284745c81 [db] deprecate caching of localized app name and summary
This led to many hard to debug issues in the past. It is easier to always fetch fresh data and not cache it.

Previously, we needed the cache as a search index. Now, search uses all localizations, so the cache isn't needed anymore.
2025-11-04 08:50:52 -03:00
Torsten Grote
290cfcee34 [db] New AppOverviewItems AppDao methods 2025-11-04 08:50:52 -03:00
Torsten Grote
b33800bf5c [db] Add more information to versions
such as versionName and added date.
Also allow passing in UpdateChecker for DbUpdateChecker
2025-11-04 08:50:51 -03:00
Torsten Grote
23dde0bc9b [db] Better support search for CJK languages
by inserting zero whitespace between their characters to help the existing sqlite FTS tokenizers to split them up.

We have considered splitting them up only at word boundaries, but after consulting native speakers decided to do splitting by chars instead.

Doing this is a hack, but due to the limitations of tokenizers currently available with sqlite, we saw no better solution. While the ICU tokenizer is available as well, it doesn't handle diacritics in other languages.

The zero whitespace is added to zh, ja and ko locales when saving their text to the database. It happens for app names, summaries and descriptions either when loading a full index or when applying diffs. Tests have been added for both cases.
2025-11-04 08:50:51 -03:00
Torsten Grote
0f3f2d6f80 [db] improve search
This now also searches in descriptions, author and package names.
The search also considers all languages now and is insensitive to diacritics in most languages.

The AppMetadataFts needed to be re-created for this to work. A migration and a test for this have been added.
2025-11-04 08:50:50 -03:00
Torsten Grote
9b5b68b740 remove non-determinism from removeAllOptionalsDiff test 2025-07-14 15:25:07 -03:00
Torsten Grote
6b304c8fa9 [db] Add test for removal of optionals from packages 2025-07-14 09:50:34 -03:00
Torsten Grote
d5fd44f718 [db] Removal of *all* packages via diff currently not supported 2025-07-14 09:50:34 -03:00
Torsten Grote
4d719af2bb [db] Fix diff removal of optionals in Repository 2025-07-14 09:50:34 -03:00
Tobias_Groza
948e22efc8 Fix and add tests for hasAuthorMoreThanOneApp(), getAppListItemsForAuthor() 2025-06-25 11:01:17 +02:00
Tobias_Groza
11c7ebf3ce De-duplicate SQL getAppListItems queries by using RawQuery 2025-06-25 11:01:17 +02:00
Tobias_Groza
fc6a88c4b7 Fix AppListLiveData.addSource()
With the update to Room 2.7.0 the chunked queries stopped to return distinct values. This is fixed by only processing distinct values when merging the chunked results.
The test case for the chunked quries was also fixed. It did not work properly before because it only tested chunked quries and not the base case which does not need chunked packageInfo
2025-05-30 16:48:41 -03:00
Thore Goebel
319ff86744 Add testAddingMidRepoByOfficialMirror 2025-05-01 14:47:59 +02:00
Torsten Grote
1955f551e1 Respect preferred repo for category apps count 2025-04-14 09:26:40 -03:00
Torsten Grote
f94e8725b8 Allow duplicate permissions in DbTest 2025-03-24 15:17:46 -03:00
Torsten Grote
8a676010ba [db] rename location to countryCode in Mirror 2024-11-07 14:36:12 -03:00
Torsten Grote
1ba3d00b78 [db] Allow AppPrefs.preferredRepoId to be set to a repo that doesn't contain the app 2024-11-07 10:17:58 -03:00
Torsten Grote
195911c765 Fixing Kotlin style issues ahead of ktlint upgrade 2024-10-17 17:41:12 +00:00
Torsten Grote
cfaf9a5ad2 [db] Fix concurrent index updates
If we are used to update the same repo at almost the same time, a race-condition can happen that tries to apply a diff to an already updated DB. We don't download anything while holding a DB transaction, so the download and check for the repo timestamp happens before we enter the transaction. However, we forgot to re-check the timestamp again within the transaction to be sure the DB state is still as expected.
2024-10-08 17:14:24 +00:00
Tobias_Groza
f927e7c86d Add test for AppMetadataFTS table migration 2024-09-03 19:06:10 +02:00
Tobias_Groza
14ffc7023b Update tests to use new db schema and migrations 2024-09-03 19:06:10 +02:00
Torsten Grote
fb041c4450 [db] Fix bug where disabled repos were considered for preferred repo calculation
If an update was available from a disabled repo with a higher priority, the update from an enabled repo with a lower priority would not be offered as an update (i.e. returned by DbUpdateChecker#getUpdatableApps()).
2024-07-09 16:02:37 +00:00
Torsten Grote
fa65084e60 [db] make repo certs non-null and remove repos without cert
historically, repos were added to the DB without much information and could stay in a broken state until manually removed. If a repo is updating, it should have a cert. So only repos that never did a single index update don't have a cert. Nowadays, this can not happen anymore as we get the repo and its cert before adding it to the DB. So whenever we update a repo, we know its certificate and fingerprint. Thus, this includes a DB migration removing all broken repos and making the certificate for repos in the DB non-null.
2024-05-22 09:58:05 +00:00
Torsten Grote
4c366403fa [db] Maintain legacy repo priority ordering when migrating 2024-04-30 10:54:55 -03:00
Torsten Grote
ef4e72e6d4 [db] handle broken repos without certificate
On versions before 1.18.0, adding a repo would add it as "empty" to the DB without a certificate right away and if there was an issue with it (e.g. typo in URL), it would stay in the DB until manually removed.
Our migration code did not consider such repos.
2024-04-05 21:32:16 +00:00
Torsten Grote
108105596d [db] allow re-ordering repo list and thus priorities 2024-02-20 09:42:40 -03:00
Torsten Grote
51a4bcec58 [db] don't allow initial repos from fixtures to provide weight
The client was already auto-incrementing their weight anyway. But it leaked our internal weight handling into the library consumer which can cause issues like when me are making changes to how we handles repo weights as we are doing now.
2024-02-20 09:42:40 -03:00
Torsten Grote
b993da8db8 [db] New repos now get lower weight than older ones
so they do not override the information from older repos anymore. This is especially an issue for the official repo which historically had the lowest priority while it should have the highest.
2024-02-20 09:42:39 -03:00
Torsten Grote
d9ea1e154b [db] Migrate repo weights and test migration 2024-02-20 09:42:39 -03:00
Torsten Grote
4a01b02fa6 [db] Add DB query for getting repos an app is in 2024-02-20 09:42:39 -03:00
Torsten Grote
ead8bd1262 [db] Only consider preferred versions for updates and suggested version 2024-02-20 09:42:39 -03:00
Torsten Grote
12af2fa32b [db] reset the preferred repo when it gets disabled or deleted 2024-02-20 09:42:38 -03:00
Torsten Grote
5c27f7033e [db] Move InstantTaskExecutorRule into base DbTest class
so all tests can use LiveData helper methods such as getOrFail() without worrying about that rule
2024-02-20 09:42:38 -03:00
Torsten Grote
704234c9df [db] allow setting a preferred repo per app 2024-02-20 09:42:38 -03:00
Torsten Grote
a5ec22fa6c [db] add queries for getting app list items by repo 2023-10-18 11:39:38 +00:00
Torsten Grote
7c9083fea1 Add test for compat flag in AppOverviewItems 2023-10-10 11:08:10 -03:00
Torsten Grote
f3e8a0a45b [db] Add plumping for fetching and adding a new repo 2023-08-21 10:52:34 +02:00
Torsten Grote
43816ffe8d [db] validate repo certificate
for now only for initial repos, but eventually we should validate for CoreRepository as well to prevent invalid certs from entering the DB by other means.
2023-08-02 09:16:44 +02:00
Torsten Grote
8d4da28936 [app] some pre-repo mirror nitpicks 2023-07-11 13:29:45 -03:00
Michael Pöhn
bcd9cc0548 🧭 add mirrors to default_repos.xml 2023-07-11 16:19:26 +00:00
Torsten Grote
7853354394 [db] Require SDK 28 for instrumentation tests 2023-06-15 10:28:40 +00:00
Torsten Grote
21f8a23814 Upgrade all (most of) the things 2023-05-30 09:39:15 -03:00
Torsten Grote
d83822510c Compile libraries with SDK 33 as well 2023-05-29 12:00:49 -03:00
Torsten Grote
7489f8466b [db] Rework AppDao#clearAll() method to fix critical bug
This is a breaking change.

The new method is in FDroidDatabase and called clearAllAppData(). It now also resets repository timestamps, so we will not try to apply a diff when we should use a full index.
2023-04-05 17:34:36 -03:00
Torsten Grote
21f40158a2 [db] escape search query
to prevent sqlite FTS search features from messing up query

Fixes acra-crash-reports#217
2023-03-14 13:28:48 +00:00
Torsten Grote
7a2d0e31f3 [db] Handle users with a thousand apps or more installed in AppDao 2023-01-13 08:41:37 +00:00
Torsten Grote
a474198c34 [db] Handle users with a thousand apps or more installed in VersionDao 2023-01-13 08:41:37 +00:00