cb0d378ded
If getMailboxLock() failed (e.g. folder not found) the try/finally cleanup block was never entered, leaving the ImapFlow connection open and leaking. Move the lock acquisition inside the try block and use lock?.release() in finally so client.logout() is always called regardless of lock success.