Bug 92745 - attachment saved by KMail is only 0 bytes, with "load attachments on demand"
Summary: attachment saved by KMail is only 0 bytes, with "load attachments on demand"
Status: RESOLVED FIXED
Alias: None
Product: kmail
Classification: Unmaintained
Component: general (show other bugs)
Version: 1.7.1
Platform: unspecified Linux
: NOR major
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
: 104896 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-11-05 14:31 UTC by Jens
Modified: 2007-09-14 12:17 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Bandprobenraum Nutzer.doc (28.00 KB, application/msword)
2004-11-06 00:51 UTC, Jens
Details
spam_complete.msg.gz (4.71 KB, application/x-gzip)
2004-11-08 15:48 UTC, Jens
Details
handleattachment.diff (16.71 KB, text/x-diff)
2005-01-16 22:49 UTC, Carsten Burghardt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jens 2004-11-05 14:31:18 UTC
Version:           1.7.1 (using KDE 3.3.1, SuSE)
Compiler:          gcc version 3.3.3 (SuSE Linux)
OS:                Linux (i686) release 2.6.5-7.111-default

Hi,

using KDE 3.3.1 (SuSE provided RPMs) on SuSE 9.1.

I have an IMAP account with "load attachments on demand" enabled in the settings. When I receive a mail with an attachment (in my case it's a MS word document called "Bandprobenraum Nutzer.doc"), KMail will only save 0 bytes (ie. create an empty file).

If I DISable "load attachments on demand", then the file is saved correctly.

If you need the actual mail to trigger the bug, please tell me, I'll attach it here.

Thanks!
Comment 1 Carsten Burghardt 2004-11-05 20:52:00 UTC
On Friday 05 November 2004 14:31, Jens B.Benecke wrote:
> If you need the actual mail to trigger the bug, please tell me, I'll attach
> it here.

Yup, please do so.

Comment 2 Jens 2004-11-06 00:51:14 UTC
Am Freitag, 5. November 2004 20:52 schrieb Carsten Burghardt:
> Yup, please do so.

Here you are. Hope Bugzilla can cope with attachments sent by mail. :)

Hallo liebe Bandprobenraum-Nutzer und Anw
Comment 3 Carsten Burghardt 2004-11-06 17:02:14 UTC
This doesn't work so please attach it gziped.

Comment 4 Jens 2004-11-06 17:28:01 UTC
Am Samstag, 6. November 2004 17:02 schrieb Carsten Burghardt:
>  This doesn't work so please attach it gziped.

I would, but ... http://bugs.kde.org/show_bug.cgi?id=92776


Comment 5 Carsten Burghardt 2004-11-07 17:10:47 UTC
Is that problem limited to that mail?

Comment 6 Jens 2004-11-08 10:05:29 UTC
close 92745
thanks

Am Sonntag, 7. November 2004 17:10 schrieb Carsten Burghardt:

> Is that problem limited to that mail?

When I reported this bug, I had it with every mail. Right now, using the 
same client, after cleaning up deleted IMAP files on the server and 
fiddling a bit with the KMail IMAP settings, and also trying KMail from 
KDE 3.3.0 that is shipped with SuSE 9.2 (SuSE claims their KDE build 
contains some "post-3.3.1 fixes"), I cannot reproduce it any more.

I'll get back to you if I manage to reproduce it - it's definitely a bug 
somewhere, but apparently it depends on more than I thought.

Thank you!

Comment 7 Stephan Kulow 2004-11-08 11:45:45 UTC
SUSE claims the build contains some post-3.3.0 fixes - it was released before 3.3.1 though.

But the bug is there and the mail has to be quite large. _And_ you have to switch folders before you can reproduce it. I don't use online imap at work, but I didn't have difficulties reproducing it with 4MB attachments.
Comment 8 Jens 2004-11-08 15:48:15 UTC
Am Montag, 8. November 2004 11:45 schrieb Stephan Kulow:

> But the bug is there and the mail has to be quite large. _And_ you have
> to switch folders before you can reproduce it. I don't use online imap
> at work, but I didn't have difficulties reproducing it with 4MB
> attachments.

Hello,

I just got two more mails which only had an email (spam, actually) attached 
which showed the same symptoms:

- with load-on-demand attachments setting, the attachment seems empty when 
clicking on the "Eingebettete Nachricht" text above it (opening in a new 
window), but *does* show in the main message view. If I right-click on 
"eingebettete Nachricht" and save to disk, only the headers are saved.

- without load-on-demand attachments, the message is displayed correctly in 
all cases.

Nothing crashed, though.




Created an attachment (id=8220)
spam_complete.msg.gz
Comment 9 Jörg Werner 2004-12-21 14:49:53 UTC
Hi,

using the latest debian packages from sid (3.3.1) I also experience this bug.
I also use Online-IMAP and from time to time when I try to save an attachment, it will save the file, but with a file size of 0 Bytes. I wasn't able to find a pattern in the kind of e-mails which reproduce this bug, but saving these attachments using mutt was never a problem. If you need some more e-mails to reproduce this problem, I can dig some up if I have to.

Cheers,

Jörg
Comment 10 Carsten Burghardt 2004-12-21 14:54:48 UTC
I still don't have an email to reproduce this so it would be good if you could find one. The mentioned problem with inlined messages is known and I'm working on it.
Comment 11 Jörg Werner 2004-12-21 15:10:25 UTC
Okay, I tried to save the attachment of the e-mail which failed yesterday, but
today it works. So it seems to me, this may have something to do if the e-mail is new or not...
Comment 12 Ferdinand Gassauer 2005-01-16 20:33:49 UTC
have the same problem with CVS from today

saving attachments from a new Email creates files of size 0

workaround "load on demand=off"
cu ferdinand
Comment 13 Ferdinand Gassauer 2005-01-16 20:38:00 UTC
changed to major, because after saving the attachments (without verifying the content) and deleting the mail, information is lost.
Comment 14 Carsten Burghardt 2005-01-16 22:45:08 UTC
On Sunday 16 January 2005 20:33, Ferdinand Gassauer wrote:
> saving attachments from a new Email creates files of size 0

Can you provide the email?

Comment 15 Carsten Burghardt 2005-01-16 22:49:39 UTC
The attached patch is against HEAD. It would be great if you give it a try and 
see if that fixes your problems.


Created an attachment (id=9125)
handleattachment.diff
Comment 16 Daniel O'Connor 2005-02-10 01:52:32 UTC
I have seen this problem consistently.. One work around that usually works is to click on the attachment first and then after loading it that way you can right click on it to save it..

That said quite often Ark will choke - it seems KMail(?) deletes the saved file after Ark has generated the index so if you try and DO anything with the archive it fails.
Comment 17 Carsten Burghardt 2005-02-11 08:36:39 UTC
This is fixed in cvs head.
Comment 18 Edward Muller 2005-04-19 21:28:11 UTC
Listed as fixed in CVS head, yet I am running KDE 3.4.0 and this happens consistently.
Comment 19 Daniel O'Connor 2005-04-20 05:01:55 UTC
Still happens here.
At one stage I was running CVS Kmail (pre 3.4.0) and it seemed to be fixed but now it's back.

You can work around it by clicking on the attachment then shift clicking later to save it, but it's kind of annoying.
Comment 20 Carsten Burghardt 2005-04-20 09:11:32 UTC
Does it happen with all attachments? How do you save the attachment?
What imap server is this?
Comment 21 Daniel O'Connor 2005-04-20 09:37:32 UTC
Seems to happen with all attachments.
Doing some experimenting reveals something interesting..

If I right click on the attachment in the message structure pane and do "save as" it works perfectly. If I shift-click on the attachment in the message pane (down the bottom) it creates 0 length files.

Even if I right click in the structure pain and save the file and then shift click down the bottom and try and save it it generates a zero byte file.

Most curious!

I am using Cyrus IMAP BTW (2.2.x)

Comment 22 Carsten Burghardt 2005-04-20 16:37:44 UTC
You could do me a favour and compile kmail with debug enabled and then get
the debug output on the console when you save an attachment.


Thanks

Carsten
Comment 23 Daniel O'Connor 2005-04-21 06:42:36 UTC
Hmm I tried rebuilding with --enable-debug=full & then installing but I don't get anything in the terminal I ran kmail from nor do I get anything in .xsession-errors :(

kdebugdialog shows the kmail entry is ticked.
Comment 24 Carsten Burghardt 2005-04-21 09:37:24 UTC
> Hmm I tried rebuilding with --enable-debug=full & then installing but I
> don't get anything in the terminal I ran kmail from nor do I get anything
> in .xsession-errors :(
>
> kdebugdialog shows the kmail entry is ticked.


Is the output from kmail redirected to a file or something (according to
kdebugdialog)? Do you get any debug messages when you start kmail (should
be tons of lines actually)?
Comment 25 Daniel O'Connor 2005-04-21 09:58:40 UTC
On Thu, 21 Apr 2005 17:07, Carsten Burghardt wrote:
> Is the output from kmail redirected to a file or something (according to
> kdebugdialog)? Do you get any debug messages when you start kmail (should
> be tons of lines actually)?


kdebugdialog doesn't show anything about files..
1 tick box per entry and kmail's is ticked.

Hmm for some reason the configure line is getting --disable-debug in it when I 
build from ports.. I'll look at it and get back to you soon!
Comment 26 Daniel O'Connor 2005-04-22 04:35:34 UTC
I set all kmail debugging to go to /tmp/kmail using 'kdebugdialog --fullmode' and got the following..

Hope it helps!

zero file save
==============
kmail: KMReaderWin  -  finished parsing and displaying of message.
kmail: processNextCheck, remaining 1
kmail: for host  current connections=0 and limit is 0
kmail: connection limit reached: false
kmail: processing next mail check for Local
kmail: processNextCheck, remaining 0
kmail: account Local finished check

good file save
==============
kmail:
**
** KMMimePartTree::itemRightClicked() **
**
kmail: ImapJob::slotGetMessageResult - retrieved part 2
kmail: KMMessage::updateBodyPart 2
kmail: ISubject::notify 1
Comment 27 Carsten Burghardt 2005-05-01 19:51:29 UTC
I can confirm this when you shift click the attachment. This is not covered by the code yet. All other cases work well.
Comment 28 Carsten Burghardt 2005-05-01 19:52:02 UTC
*** Bug 104896 has been marked as a duplicate of this bug. ***
Comment 29 Carsten Burghardt 2005-05-11 21:18:43 UTC
SVN commit 412471 by burghard:

Handle shift-click ourself and load the attachment if necessary. Thanks to David for the QScrollView help.
BUGS:92745


 M  +19 -0     trunk/KDE/kdepim/kmail/kmreaderwin.cpp  
 M  +3 -0      trunk/KDE/kdepim/kmail/kmreaderwin.h  


--- trunk/KDE/kdepim/kmail/kmreaderwin.cpp #412470:412471
@@ -1002,6 +1002,8 @@
   mViewer->setURLCursor(KCursor::handCursor());
   // Espen 2000-05-14: Getting rid of thick ugly frames
   mViewer->view()->setLineWidth(0);
+  // register our own event filter for shift-click
+  mViewer->view()->viewport()->installEventFilter( this );
 
   if ( !htmlWriter() )
 #ifdef KMAIL_READER_HTML_DEBUG
@@ -2398,6 +2400,23 @@
   return QString::null;
 }
 
+//-----------------------------------------------------------------------------
+bool KMReaderWin::eventFilter( QObject *, QEvent *e )
+{
+  if ( e->type() == QEvent::MouseButtonPress ) {
+    QMouseEvent* me = static_cast<QMouseEvent*>(e);
+    if ( me->button() == LeftButton && ( me->state() & ShiftButton ) ) {
+      // special processing for shift+click
+      mAtmCurrent = msgPartFromUrl( mUrlClicked );
+      mAtmCurrentName = mUrlClicked.path();
+      slotHandleAttachment( KMHandleAttachmentCommand::Save ); // save
+      return true; // eat event
+    }
+  }
+  // standard event processing
+  return false;
+}
+
 #include "kmreaderwin.moc"
 
 
--- trunk/KDE/kdepim/kmail/kmreaderwin.h #412470:412471
@@ -402,6 +402,9 @@
   /** Cleanup the attachment temp files */
   virtual void removeTempFiles();
 
+  /** Event filter */
+  bool eventFilter( QObject *obj, QEvent *ev );
+
 private:
   void adjustLayout();
   void createWidgets();
Comment 30 Dennis Nigbur 2005-08-10 16:29:38 UTC
I can confirm this behaviour on KMail 1.8.2 using KDE 3.4.2, installed from SuSE 9.2 RPMs. The workaround of disabling load-on-demand works here too. 

If this problem proves hard to repair, it may be worth setting KMail to disable load-on-demand by default until it is solved. Otherwise, data loss seems inevitable.
Comment 31 Carsten Burghardt 2005-08-10 17:04:25 UTC
> I can confirm this behaviour on KMail 1.8.2 using KDE 3.4.2, installed
> from SuSE 9.2 RPMs. The workaround of disabling load-on-demand works here
> too.


That crept in 3.4.2 but is already fixed in 3.4 branch and 3.5