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 newModules = ArrayList<RepoModule>()
val len = jsonArray.length() 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 var lastLastUpdate: Long = 0
for (i in 0 until len) { for (i in 0 until len) {
jsonObject = jsonArray.getJSONObject(i) jsonObject = jsonArray.getJSONObject(i)

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

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

Loading…
Cancel
Save