Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit be96b6e5 authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #3910 from k9mail/fix_K9BackendFolder

Fix bug in K9BackendFolder.getLastUid()
parents e65daf5c 7a41c018
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ class K9BackendFolder(
    }

    override fun getLastUid(): Long? {
        return database.rawQuery("SELECT MAX(uid) FROM messages WHERE folder_id = ?", folderServerId) { cursor ->
        return database.rawQuery("SELECT MAX(uid) FROM messages WHERE folder_id = ?", databaseId) { cursor ->
            if (cursor.moveToFirst()) {
                cursor.getLongOrNull(0)
            } else {
+10 −0
Original line number Diff line number Diff line
@@ -75,6 +75,16 @@ class K9BackendFolderTest : K9RobolectricTest() {
        assertEquals(flags, messageFlags)
    }

    @Test
    fun getLastUid() {
        createMessage("200")
        createMessage("123")

        val lastUid = backendFolder.getLastUid()

        assertEquals(200L, lastUid)
    }


    fun createAccount(): Account {
        //FIXME: This is a hack to get Preferences into a state where it's safe to call newAccount()