Bug 352223

Summary: Sent mails are not syncronized to the server
Product: [Frameworks and Libraries] kimap Reporter: Antonio Rojas <arojas>
Component: generalAssignee: Christian Mollekopf <chrigi_1>
Status: RESOLVED FIXED    
Severity: major CC: daniel, johannes, kdepim-bugs, vkrause
Priority: NOR    
Version: git   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Patch

Description Antonio Rojas 2015-09-03 14:30:44 UTC
Since updating to 15.08, the sent mails are not syncronized with the IMAP server. The mails are displayed in kmail's Sent folder, but they don't appear in the server. I can move the sent messages to other folders, and it doesn't make any difference: they are completely missing from the server. This is a disconnected IMAP account.

Reproducible: Always

Steps to Reproduce:
1. Send a mail
2. Check that it is stored in the Sent folder

Actual Results:  
The mail should be in the Sent folder in the server

Expected Results:  
The mail is nowhere to be found on the server

Setting as major as this can lead to data loss if the user doesn't realize that the mail is not in the server and removes the Akonadi cached copy.
Comment 1 Antonio Rojas 2015-09-03 14:41:38 UTC
The Akonadi console shows this error:

AgentBase(akonadi_imap_resource_0): Agregar falló, el servidor respondió: A004895 BAD Error in IMAP command APPEND: Invalid internal date ( 0.000 secs ) . 

Also, this doesn't happen with my Gmail accounts, only with my work account.
Comment 2 Daniel Eklöf 2015-09-05 09:47:38 UTC
Looks like a dup of bug 351838, that I reported a while ago.
Comment 3 Antonio Rojas 2015-09-05 11:56:43 UTC
Looks similar, although the error message is slightly different. Reassigning to kimap, which is where the actual APPEND operation takes place. 
This commit looks like a likely candidate to being the cause of this, unfortunately with all the splitting of kdepimlibs into multiple interdependent libraries, trying to bisect something is a nightmare.

https://quickgit.kde.org/?p=kimap.git&a=commit&h=afdb02561333be40ae385ee4e16c30027b52f3f9
Comment 4 Daniel Eklöf 2015-09-05 12:47:58 UTC
From that commit, one can see that the KDateDate format string was using "%:b" wich, from the documentation, is the abbreviated month _in english_.

  http://api.kde.org/4.9-api/kdelibs-apidocs/kdecore/html/classKDateTime.html#a506bae364393fdb665926532917e9bc2

The QDateTime format string just uses "MMM", which also means the abbreviated name of the month, but in the current locale. That doesn't seem right.

Furthermore, it uses "hh" for the hours, which can be either 00-23, or 01-12 if locale uses AM/PM. It should probably use "HH" instead.

  http://doc.qt.io/qt-5/qdatetime.html#toString
Comment 5 Antonio Rojas 2015-09-05 12:53:12 UTC
(In reply to Daniel Eklöf from comment #4)
> From that commit, one can see that the KDateDate format string was using
> "%:b" wich, from the documentation, is the abbreviated month _in english_.
> 
>  
> http://api.kde.org/4.9-api/kdelibs-apidocs/kdecore/html/classKDateTime.
> html#a506bae364393fdb665926532917e9bc2
> 
> The QDateTime format string just uses "MMM", which also means the
> abbreviated name of the month, but in the current locale. That doesn't seem
> right.
> 
> Furthermore, it uses "hh" for the hours, which can be either 00-23, or 01-12
> if locale uses AM/PM. It should probably use "HH" instead.
> 
>   http://doc.qt.io/qt-5/qdatetime.html#toString

I restarted akonadi with LANG=C and this isn't reproducible, so it looks like you're on the right track.
Comment 6 Antonio Rojas 2015-09-05 13:53:32 UTC
Created attachment 94412 [details]
Patch

This patch fixes the issue for me
Comment 7 Volker Krause 2015-09-05 14:19:19 UTC
Git commit 5baa874efeee6cdb28995037ed9184a7fb822d36 by Volker Krause.
Committed on 05/09/2015 at 14:19.
Pushed by vkrause into branch 'Applications/15.08'.

Don't localize the date here, this is part of the IMAP protocol.

Fix by Antonio Rojas.

M  +1    -1    src/appendjob.cpp

http://commits.kde.org/kimap/5baa874efeee6cdb28995037ed9184a7fb822d36
Comment 8 Daniel Eklöf 2015-09-05 14:42:00 UTC
*** Bug 351838 has been marked as a duplicate of this bug. ***
Comment 9 Johannes Studt 2015-09-08 19:04:15 UTC
(In reply to Antonio Rojas from comment #5)
> I restarted akonadi with LANG=C and this isn't reproducible, so it looks
> like you're on the right track.

As I'm also facing this problem (and this patch hasn't landed in the distro's package repository) I tried your work-around and consequently all works fine. :)

Now, as I become aware of this problem much too late (and would have to manually re-sync many e-mails in many different folders), is there a simple way to force resync of the whole IMAP tree at once?
Forcing resync in akonadiconsole doesn't trigger a re-upload of the server-side missing e-mails. I have to *copy* them, simply *move* them temporarily in another folder isn't enough.

TIA, and regards,

Hannes