As v1 images don't have a sha256 hash, we were using the name as the glide cache key. In some cases (e.g. repo icons), this caused false re-use of a cached image. Now we use the first mirror and the file name as the cache key.
Also add a DigestInputStream variant, so we can verify the SHA-256 hash while reading from the stream.
This can be useful when we don't want to save a file, but already process a download while downloading.
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.
I can't really figure out this specific issue, but seems like it
should skip apps after NameNotFoundException regardless of why. This
is used elsewhere, like `DbUpdateChecker.getSuggestedVersion()`.
Here's the error that I saw on CalyxOS:
```
android.content.pm.PackageManager$NameNotFoundException: org.calyxos.customization
at android.app.ApplicationPackageManager.getPackageInfoAsUser(ApplicationPackageManager.java:253)
at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:213)
at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:207)
at org.fdroid.index.v1.IndexV1Creator.addApp(IndexV1Creator.kt:67)
at org.fdroid.index.v1.IndexV1Creator.createIndex(IndexV1Creator.kt:49)
at org.fdroid.index.v1.IndexV1Creator.createRepo(IndexV1Creator.kt:37)
at org.fdroid.fdroid.nearby.LocalRepoManager.generateIndex(LocalRepoManager.java:259)
at org.fdroid.fdroid.nearby.LocalRepoService.runProcess(LocalRepoService.java:107)
at org.fdroid.fdroid.nearby.LocalRepoService$GenerateLocalRepoThread.run(LocalRepoService.java:96)
```
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.
With index-v2, "signer" will be the only field used, since "sig" is
deprecated and should be removed. "sig" needs to be kept only for
generating the index-v1.jar in nearby/swap repos so that it remains
compatible with older clients. This code base should no longer use
"sig" for anything besides writing it out to index-v1.json.
libs/database/src/dbTest/java/org/fdroid/database/AppListItemsTest.kt:68:1 Exceeded max line length (100) (cannot be auto-corrected) (max-line-length)
libs/database/src/dbTest/java/org/fdroid/database/AppListItemsTest.kt:121:1 Exceeded max line length (100) (cannot be auto-corrected) (max-line-length)
Roboletric apparently does not support Os.symlink, and some devices might
have wonky implementations. Copying is slower and takes more disk space,
but is much more reliable. So it is a workable fallback.