From c35c1040a3f023b052adb232c1e3dd33fdba1c46 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Mon, 15 Apr 2024 10:29:59 +0200 Subject: [PATCH] =?UTF-8?q?Folder=20m=C3=A5=20eksistere=20for=20=C3=A5=20r?= =?UTF-8?q?ename?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smtp-listeners/src/main/kotlin/no/nav/emottak/smtp/Routes.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/smtp-listeners/src/main/kotlin/no/nav/emottak/smtp/Routes.kt b/smtp-listeners/src/main/kotlin/no/nav/emottak/smtp/Routes.kt index c0bb1ebd..deda0a7c 100644 --- a/smtp-listeners/src/main/kotlin/no/nav/emottak/smtp/Routes.kt +++ b/smtp-listeners/src/main/kotlin/no/nav/emottak/smtp/Routes.kt @@ -10,6 +10,7 @@ import io.ktor.server.routing.Route import io.ktor.server.routing.get import jakarta.mail.Flags import jakarta.mail.Folder +import jakarta.mail.Folder.HOLDS_MESSAGES import jakarta.mail.internet.MimeMultipart import kotlinx.coroutines.Deferred import kotlinx.coroutines.Dispatchers @@ -304,6 +305,7 @@ fun Folder.deleteAll() { if (this is IMAPFolder) { if (isOpen) close() val deleteMeFolder = getFolder("DeleteMe") + if (!deleteMeFolder.exists()) create(HOLDS_MESSAGES) this.renameTo(deleteMeFolder) deleteMeFolder.delete(true) log.info("${this.fullName} deleted.")