Skip to content

Commit 8a320a6

Browse files
authored
Merge pull request #33 from qhy040404/fix/lc-1037
2 parents 0655467 + 01e6d91 commit 8a320a6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

library/src/main/java/com/absinthe/rulesbundle/Repositories.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ object Repositories {
2020
val localCloudVersionFile = File(context.filesDir, LOCAL_RULES_VERSION_FILE)
2121
if (localCloudVersionFile.exists().not()) return LCRules.getVersion()
2222
if (localCloudVersionFile.isDirectory.not()) return LCRules.getVersion()
23-
localCloudVersionFile.listFiles()?.takeIf { it.isNotEmpty() }?.let {
24-
return runCatching { it[0].name.toInt() }.getOrDefault(LCRules.getVersion())
23+
localCloudVersionFile.listFiles()?.takeIf { it.isNotEmpty() }?.let { files ->
24+
return runCatching { files.maxOf { it.name.toInt() } }.getOrDefault(LCRules.getVersion())
2525
} ?: return LCRules.getVersion()
2626
}
2727

@@ -54,8 +54,8 @@ object Repositories {
5454
val versionFile = File(context.filesDir, LOCAL_RULES_VERSION_FILE)
5555
if (versionFile.exists().not()) return false
5656
if (versionFile.isDirectory.not()) return false
57-
versionFile.listFiles()?.takeIf { it.isNotEmpty() }?.let {
58-
val version = runCatching { it[0].name.toInt() }.getOrDefault(0)
57+
versionFile.listFiles()?.takeIf { it.isNotEmpty() }?.let { files ->
58+
val version = runCatching { files.maxOf { it.name.toInt() } }.getOrDefault(0)
5959
return version >= LCRules.getVersion()
6060
} ?: return false
6161
}

0 commit comments

Comments
 (0)