This project is read-only.

Possible bug getting Folders on dovecot

Topics: Issues
Dec 26, 2013 at 5:02 PM
Hi,

I'm trying out ImapX and just put together a super simple login to a local dovecot served Imap source, using the F# below. When it comes to enumerate the folders, line 175 in ImapClient.cs
e.g. var folder = Folder.Parse(data[i], ref parent, this); gets a null as the first data item and the next line fails processing the folder info. The reason appears to be that the IMAP server is returning an OK line before providing the folder details and that first OK line is messing up the folder data parsing. Example output here. I think I can probably patch it but have you seen this before and am I doing anything else wrong? Looks like a nice library and I'd really like to get it working with my project,

Thanks in advance,
Darren

data
Count = 113
[0]: "* OK [CLOSED] Previous mailbox closed."
[1]: "* LIST (\\Noselect \\HasChildren) \"/\" \"p/\""
[2]: "* LIST (\\NoInferiors \\UnMarked) \"/\" \"p/klt\""
[3]: "* LIST (\\NoInferiors \\UnMarked) \"/\" \"p/gdavis\""
[4]: "* LIST (\\NoInferiors \\UnMarked) \"/\" \"p/marks\""
    let host = "xxxx.xx"
    let port = 993
    let useSSL = true
    let validateServerCert = false

    let userName = "xxx"
    let password = "xxxxxx"

    use client =  new ImapClient(host,port,useSSL,validateServerCert)
    if client.Connect() then
        if client.Login(userName,password) then
            // Succesful login
            let folders = client.Folders
            for folder in folders do
                printfn"Folder: %s  %s" folder.Name folder.Path
Dec 26, 2013 at 5:22 PM
This patch seems to make it work , not processing the empty entries but not sure if there are other unintended consequences,

Darren
                // DP: 20131226
                if (folder != null)
                {
                    commonFolders.TryBind(ref folder);

                    if (Behavior.ExamineFolders)
                        folder.Examine();

                    if (folder.HasChildren && (isFirstLevel || Behavior.FolderTreeBrowseMode == FolderTreeBrowseMode.Full))
                        folder.SubFolders = GetFolders(folder.Path + Behavior.FolderDelimeter, commonFolders, folder);

                    result.AddInternal(folder);
                }
Coordinator
Dec 26, 2013 at 8:44 PM
Hi Darren,

thank you really much! I will take a closer look at the code and include your fix, checking if anything else uis getting affected.

Greets,

Pavel
Dec 26, 2013 at 10:38 PM
Thanks for the quick reply! Dovecot probably has slightly different behaviour. Will let you know what else I find. You need a set of unit tests against a server if you don't have one already. I might write some tests if I have a chance. �Thanks again Darren
On Thu, Dec 26, 2013 at 12:44:46PM -0800, pavel_azanov wrote: