You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cache is actually introducing regressions in performance and the android repo now responds faster than we can read from a database
other repos still suck performance wise but caching those gets super tricky and runs into similar performance problems
Signed-off-by: androidacy-user <opensource@androidacy.com>
if (BuildConfig.DEBUG) Timber.d("Repo $preferenceId updated: $diffMinutes minutes ago")
401
-
db.close()
402
-
db2.close()
403
-
diffMinutes >if (BuildConfig.DEBUG) 15else30
404
-
} else {
405
-
if (BuildConfig.DEBUG) Timber.d("Repo $preferenceId shouldUpdate true: lastUpdate is "+ repo.lastUpdate +" and moduleListCache is "+ moduleListCache.size)
406
-
db.close()
407
-
db2.close()
408
-
true
409
-
}
410
-
} else {
411
-
db.close()
412
-
db2.close()
413
-
}
379
+
Timber.w("shouldUpdate() called but cache not implemented for %s", preferenceId)
if (BuildConfig.DEBUG) Timber.d("Returning %d modules for %s", toUpdate!!.size, repoData.preferenceId)
111
126
// Return repo to update
112
127
return toUpdate!!.size
113
128
}
@@ -158,194 +173,6 @@ class RepoUpdater(repoData2: RepoData) {
158
173
val success =AtomicBoolean(false)
159
174
if (BuildConfig.DEBUG) Timber.d("Finishing update for %s", repoData.preferenceId)
160
175
if (indexRaw !=null) {
161
-
val tmpIndexRaw = indexRaw!!
162
-
if (BuildConfig.DEBUG) Timber.d("Updating database for %s", repoData.preferenceId)
163
-
// new thread to update the database
164
-
val thread =Thread {
165
-
val startTime =System.currentTimeMillis()
166
-
if (BuildConfig.DEBUG) Timber.d("Updating database thread for %s", repoData.preferenceId)
167
-
try {
168
-
// iterate over modules, using this.supportedProperties as a template to attempt to get each property from the module. everything that is not null is added to the module
169
-
// use room to insert to
170
-
// props avail:
171
-
val db =Room.databaseBuilder(
172
-
MainApplication.INSTANCE!!,
173
-
ModuleListCacheDatabase::class.java,
174
-
"ModuleListCache.db"
175
-
).build()
176
-
// all except first six can be null
177
-
// this.indexRaw is the raw index file (json)
178
-
val modules =JSONObject(String(tmpIndexRaw, StandardCharsets.UTF_8))
179
-
// androidacy repo uses "data" key, others should use "modules" key. Both are JSONArrays
180
-
val modulesArray =try {
181
-
modules.getJSONArray("data")
182
-
} catch (e:Exception) {
183
-
modules.getJSONArray("modules")
184
-
} catch (e:Exception) {
185
-
Timber.e(e)
186
-
Timber.w("No modules were found in the index file for %s", repoData.preferenceId)
187
-
if (BuildConfig.DEBUG) Timber.d("Finished updating database for %s in %dms", repoData.preferenceId, System.currentTimeMillis() - startTime)
188
-
success.set(false)
189
-
return@Thread
190
-
}
191
-
if (BuildConfig.DEBUG) Timber.d("Got modules for %s", repoData.preferenceId)
0 commit comments