[Kde-pim] trying to understand akonadi

Martin Koller kollix at aon.at
Wed Oct 16 19:45:06 BST 2013


On Wednesday 16 October 2013 20:06:16 Kevin Krammer wrote:
> Hi,
> 
> Am Mittwoch, 2013-10-16, 19:47:00 schrieb Martin Koller:
> > Hi,
> > 
> > I have a problem with kmail (4.11.2) where my mbox resource (which is filled
> > from an external program) often shows a mail with
> > subject/sender/date:Unknown.
> > 
> > Currently I have such a mail and I try to find out what's going on in
> > akonadi. This mbox file has a few other mails (e.g. grep ^Date: finds 4
> > lines), but only 1 is shown (I assume the others are already marked/stored
> > internally by the mbox resource as deleted, which is fine). The one shown
> > is the "unknown" problem.
> 
> [snip analysis]
> 
> > I have no idea what this columns shall contain, but checking some other
> > entries shows that the PLD:ENVELOPE record should contain something useful
> > in the data field (Date, subject, etc.). So this situation would explain
> > why I see "unknown" as the data holds "NIL ..."
> > 
> > Any idea why this can happen ?
> > Who fills that fiels and when ?
> 
> One possible reason could be that the mbox resource is acting to quickly to 
> the file change notification.
> I.e. maybe the resource starts parsing the new mail before it is ready.

this should not happen as both lock the file.
Also in this case, the mbox entry (the From ... header) shows a date/time of 2013-10-16T17:40:18
but in akonadi I see 2013-10-16 17:40:23

As the external program is written by me, I checked its code and it mainly does:
  Lockfile lockfile(mboxfile);
  lock();
  QFile mailbox(mboxfile);
  mailbox.open(QIODevice::Append);
... getting data ...
      mailbox.write(QByteArray("From airsyncDownload at local.local ") +
                    QDateTime::currentDateTime().toString(Qt::ISODate).toUtf8() + "\n");
      mailbox.write(fullMail.toUtf8());
      mailbox.write("\n\n");
...
  unlock(); // in dtor of Lockfile

hmmm... unlocking happens in the dtor of my Lockfile class and closing the QFile also
happens in the dtor. When the destruction happens in the reverse order of construction, then the code is ok.

The lock() does (AFAIR I took the code from MBox::lock ProcmailLockfile):
    bool lock()
    {
      QStringList args;
      args << QLatin1String("-l20") << QLatin1String("-r5")
           << QString::fromLocal8Bit(QFile::encodeName(lockfile));

      int rc = QProcess::execute(QLatin1String("lockfile"), args );
      return (rc == 0);
    }

> Does the other process replace the mbox file (atomic write using move) or does 
> it append to the file?

append.

If you want to see it in detail: http://qt-apps.org/content/show.php/airsyncDownload?content=158196


I just made a test to see if the mbox file is really ok, so I copied it and created a new
mbox account with that file - everything ok, I see 4 mails.

can I somehow force kmail to re-read the mail ? (update folder does not change anything).
Sometimes I have seen that when selecting such a mail and apply the filters (CTRL-J)
the mail suddenly is moved correctly to the target folder and there it is shown with all
details.

-- 
Best regards/Schöne Grüße

Martin
A: Because it breaks the logical sequence of discussion
Q: Why is top posting bad?

()  ascii ribbon campaign - against html e-mail 
/\  www.asciiribbon.org   - against proprietary attachments

Geschenkideen, Accessoires, Seifen, Kulinarisches: www.bibibest.at
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list