1
0
mirror of https://github.com/mamoe/mirai.git synced 2025-04-25 13:03:35 +08:00

Fix AbsoluteFolder.resolveFileById for recursive ()

```kotlin
@Test
    fun testFirst() {
        val f = { a: Int ->
            if (a > 0) a
            else null
        }

        val a = listOf<Int>(-1, -2, -1, -1)
        
        assertEquals(
            a.map{ f(it) }.firstOrNull(),
            null
        )
    }
```
This commit is contained in:
ryoii 2022-05-16 01:48:52 +08:00 committed by GitHub
parent c6b47a3231
commit bc8fea2195
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -389,7 +389,7 @@ internal class AbsoluteFolderImpl(
if (!deep) return null
return folders().map { it.resolveFileById(id, deep) }.firstOrNull()
return folders().map { it.resolveFileById(id, deep) }.firstOrNull{ it != null }
}
override suspend fun resolveFiles(path: String): Flow<AbsoluteFile> {
@ -495,4 +495,4 @@ internal class AbsoluteFolderImpl(
result = 31 * result + contentsCount.hashCode()
return result
}
}
}