Skip to content

Commit 8976c0b

Browse files
fix edge case
Signed-off-by: androidacy-user <opensource@androidacy.com>
1 parent 265a39e commit 8976c0b

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

app/src/main/kotlin/com/fox2code/mmm/androidacy/AndroidacyRepoData.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,12 @@ class AndroidacyRepoData(cacheRoot: File?, testMode: Boolean) : RepoData(
306306
}
307307
val newModules = ArrayList<RepoModule>()
308308
val len = jsonArray.length()
309+
// stringify json array for logging but only log the first 200 characters
310+
val tempJsonArray = jsonArray.toString()
311+
Timber.d(
312+
"AndroidacyRepoData populate loop start with json %s",
313+
if (tempJsonArray.length > 200) tempJsonArray.substring(0, 200) else tempJsonArray
314+
)
309315
var lastLastUpdate: Long = 0
310316
for (i in 0 until len) {
311317
jsonObject = jsonArray.getJSONObject(i)

app/src/main/kotlin/com/fox2code/mmm/manager/ModuleManager.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,13 @@ class ModuleManager private constructor() : SyncManager() {
203203
var modules: HashMap<String, LocalModuleInfo> = HashMap()
204204
get() {
205205
afterScan()
206-
return moduleInfos
206+
return field
207207
}
208208
set(value) {
209-
moduleInfos = value
210209
field = value
210+
moduleInfos = value
211211
}
212+
212213
@Suppress("unused")
213214
fun getUpdatableModuleCount(): Int {
214215
afterScan()

app/src/main/kotlin/com/fox2code/mmm/repo/RepoData.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ open class RepoData(url: String, cacheRoot: File) : XRepo() {
427427
).allowMainThreadQueries().build()
428428
val moduleListCache = db2.moduleListCacheDao().getByRepoId(preferenceId!!)
429429
if (repo != null) {
430-
return if (repo.lastUpdate != 0 && moduleListCache.isNotEmpty()) {
430+
return if (repo.lastUpdate != 0 && moduleListCache.isNotEmpty() && moduleListCache.size > 1) {
431431
val lastUpdate = repo.lastUpdate.toLong()
432432
val currentTime = System.currentTimeMillis()
433433
val diff = currentTime - lastUpdate
@@ -437,8 +437,7 @@ open class RepoData(url: String, cacheRoot: File) : XRepo() {
437437
db2.close()
438438
diffMinutes > if (BuildConfig.DEBUG) 15 else 30
439439
} else {
440-
Timber.d("Repo $preferenceId should update could not find repo in database")
441-
Timber.d("This is probably an error, please report this to the developer")
440+
Timber.d("Repo $preferenceId shouldUpdate true: lastUpdate is " + repo.lastUpdate + " and moduleListCache is " + moduleListCache.size)
442441
db.close()
443442
db2.close()
444443
true

0 commit comments

Comments
 (0)