forked from recloudstream/cloudstream
Probably fixed a very weird exception
This commit is contained in:
parent
e7d7639776
commit
3fa82cdba7
1 changed files with 4 additions and 3 deletions
|
@ -38,8 +38,9 @@ class APIRepository(val api: MainAPI) {
|
||||||
val hash: Pair<String, String>
|
val hash: Pair<String, String>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// This really does not need to be Nullable but it can crash otherwise, probably caused by replacing items while looping over them.
|
||||||
private val cache: ArrayList<SavedLoadResponse> = arrayListOf()
|
// "Attempt to invoke .... getHash() on a null object reference"
|
||||||
|
private val cache: ArrayList<SavedLoadResponse?> = arrayListOf()
|
||||||
private var cacheIndex: Int = 0
|
private var cacheIndex: Int = 0
|
||||||
const val cacheSize = 20
|
const val cacheSize = 20
|
||||||
}
|
}
|
||||||
|
@ -60,7 +61,7 @@ class APIRepository(val api: MainAPI) {
|
||||||
|
|
||||||
for (item in cache) {
|
for (item in cache) {
|
||||||
// 10 min save
|
// 10 min save
|
||||||
if (item.hash == lookingForHash && (unixTime - item.unixTime) < 60 * 10) {
|
if (item?.hash == lookingForHash && (unixTime - item.unixTime) < 60 * 10) {
|
||||||
return@safeApiCall item.response
|
return@safeApiCall item.response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue