fix edge case

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/89/head
androidacy-user 2 years ago
parent 265a39eb20
commit 8976c0bd62

@ -306,6 +306,12 @@ class AndroidacyRepoData(cacheRoot: File?, testMode: Boolean) : RepoData(
}
val newModules = ArrayList<RepoModule>()
val len = jsonArray.length()
// stringify json array for logging but only log the first 200 characters
val tempJsonArray = jsonArray.toString()
Timber.d(
"AndroidacyRepoData populate loop start with json %s",
if (tempJsonArray.length > 200) tempJsonArray.substring(0, 200) else tempJsonArray
)
var lastLastUpdate: Long = 0
for (i in 0 until len) {
jsonObject = jsonArray.getJSONObject(i)

@ -203,12 +203,13 @@ class ModuleManager private constructor() : SyncManager() {
var modules: HashMap<String, LocalModuleInfo> = HashMap()
get() {
afterScan()
return moduleInfos
return field
}
set(value) {
moduleInfos = value
field = value
moduleInfos = value
}
@Suppress("unused")
fun getUpdatableModuleCount(): Int {
afterScan()

@ -427,7 +427,7 @@ open class RepoData(url: String, cacheRoot: File) : XRepo() {
).allowMainThreadQueries().build()
val moduleListCache = db2.moduleListCacheDao().getByRepoId(preferenceId!!)
if (repo != null) {
return if (repo.lastUpdate != 0 && moduleListCache.isNotEmpty()) {
return if (repo.lastUpdate != 0 && moduleListCache.isNotEmpty() && moduleListCache.size > 1) {
val lastUpdate = repo.lastUpdate.toLong()
val currentTime = System.currentTimeMillis()
val diff = currentTime - lastUpdate
@ -437,8 +437,7 @@ open class RepoData(url: String, cacheRoot: File) : XRepo() {
db2.close()
diffMinutes > if (BuildConfig.DEBUG) 15 else 30
} else {
Timber.d("Repo $preferenceId should update could not find repo in database")
Timber.d("This is probably an error, please report this to the developer")
Timber.d("Repo $preferenceId shouldUpdate true: lastUpdate is " + repo.lastUpdate + " and moduleListCache is " + moduleListCache.size)
db.close()
db2.close()
true

Loading…
Cancel
Save