Don't call open()
from RealImapFolder.expungeUids()
This commit is contained in:
parent
57ed8da230
commit
2ae56aa548
2 changed files with 15 additions and 3 deletions
|
@ -1083,6 +1083,7 @@ internal class RealImapFolder(
|
|||
}
|
||||
|
||||
override fun expungeUids(uids: List<String>) {
|
||||
checkOpen()
|
||||
expungeUids(uids, fullExpungeFallback = true)
|
||||
}
|
||||
|
||||
|
@ -1093,9 +1094,6 @@ internal class RealImapFolder(
|
|||
private fun expungeUids(uids: List<String>, fullExpungeFallback: Boolean) {
|
||||
require(uids.isNotEmpty()) { "expungeUids() must be called with a non-empty set of UIDs" }
|
||||
|
||||
open(OpenMode.READ_WRITE)
|
||||
checkOpen()
|
||||
|
||||
try {
|
||||
if (connection!!.isUidPlusCapable) {
|
||||
val longUids = uids.map { it.toLong() }.toSet()
|
||||
|
|
|
@ -1099,10 +1099,23 @@ class RealImapFolderTest {
|
|||
verify(imapConnection).executeSimpleCommand("EXPUNGE")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `expungeUids() on closed folder should throw`() {
|
||||
val folder = createFolder("Folder")
|
||||
|
||||
assertFailure {
|
||||
folder.expungeUids(listOf("1"))
|
||||
}.isInstanceOf<MessagingException>()
|
||||
.hasMessage("Folder Folder is not open.")
|
||||
|
||||
verifyNoMoreInteractions(imapConnection)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun expungeUids_withUidPlus_shouldIssueUidExpungeCommand() {
|
||||
val folder = createFolder("Folder")
|
||||
prepareImapFolderForOpen(OpenMode.READ_WRITE)
|
||||
folder.open(OpenMode.READ_WRITE)
|
||||
whenever(imapConnection.isUidPlusCapable).thenReturn(true)
|
||||
|
||||
folder.expungeUids(listOf("1"))
|
||||
|
@ -1114,6 +1127,7 @@ class RealImapFolderTest {
|
|||
fun expungeUids_withoutUidPlus_shouldIssueExpungeCommand() {
|
||||
val folder = createFolder("Folder")
|
||||
prepareImapFolderForOpen(OpenMode.READ_WRITE)
|
||||
folder.open(OpenMode.READ_WRITE)
|
||||
whenever(imapConnection.isUidPlusCapable).thenReturn(false)
|
||||
|
||||
folder.expungeUids(listOf("1"))
|
||||
|
|
Loading…
Reference in a new issue