Skip to content

Commit

Permalink
Update test indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
Iamlooker committed Sep 10, 2024
1 parent 2a87432 commit 93cebe4
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 336,222 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import com.looker.sync.fdroid.v2.model.Entry
import com.looker.sync.fdroid.v2.model.IndexV2
import com.looker.sync.fdroid.v2.model.IndexV2Diff
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.json.Json
Expand Down Expand Up @@ -46,7 +47,7 @@ class EntrySyncable(

@OptIn(ExperimentalSerializationApi::class)
override suspend fun sync(repo: Repo): Pair<Fingerprint, IndexV2?> =
withContext(Dispatchers.IO) {
withContext(dispatcher) {
// example https://apt.izzysoft.de/fdroid/repo/entry.json
val jar = downloader.downloadIndex(
context = context,
Expand All @@ -57,6 +58,7 @@ class EntrySyncable(
val (fingerprint, entry) = parser.parse(jar, repo)
jar.delete()
val index = entry.getDiff(repo.versionInfo.timestamp)
// Already latest
?: return@withContext fingerprint to null
val indexPath = repo.address.removeSuffix("/") + index.name
val indexFile = Cache.getIndexFile(context, "repo_${repo.id}_$INDEX_V2_NAME")
Expand All @@ -69,6 +71,7 @@ class EntrySyncable(
fileName = "diff_${repo.versionInfo.timestamp}.json",
diff = true,
)
// TODO: Maybe parse in parallel
diffParser.parse(diffFile, repo).second.let {
diffFile.delete()
it.patchInto(indexParser.parse(indexFile, repo).second) { index ->
Expand Down
Loading

0 comments on commit 93cebe4

Please sign in to comment.