Bug 108172

Summary: Moving Folders loses their contents
Product: [Unmaintained] kmail Reporter: Alain Knaff <kde>
Component: IMAPAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED UNMAINTAINED    
Severity: grave CC: bjoern
Priority: NOR    
Version: 1.8.1   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Alain Knaff 2005-06-26 19:11:19 UTC
Version:           1.8.1 (using KDE 3.4.1 Level "a" , SUSE 9.3 UNSUPPORTED)
Compiler:          gcc version 3.3.5 20050117 (prerelease) (SUSE Linux)
OS:                Linux (i686) release 2.6.10

Severity: CRITICAL

I noticed that Kmail has a new "Move Folder To" menu item in the right button context menu.

However, this functionality is very dangerous, as it actually deletes the folders, rather moving them.

When I tried to move the folder Linux/Events.old to 00old/Linux/Events.old, it asked me whether the folder should contain messages or subfolders (already odd: obviously the same as the source!), so I chose subfolders (Linux/Events.old was a folder of subfolders), and as soon as I clicked ok, the source was gone, the target was there, but completely empty!
Comment 1 Carsten Burghardt 2005-06-27 09:09:48 UTC
Sorry for the loss, but this was a user error.
The reason for this is simple: you are obviously running an uw-imap server that can not handle folders that have content and subfolders. And when you choose "Subfolder" you created a directory which can not have content. I'll check if it is possible to rollback in this case.
Comment 2 Alain Knaff 2005-06-27 22:04:14 UTC
Still, shouldn't there be a very obvious warning in such a situation (such as "Your IMAP server is broken. If you chose to procede anyways, data loss may occur". There is no way a normal user would know that choosing Subfolder will destroy the folder rather than moving it.

In the meantime, I tried recovering the data at the reiserfs level, to no avail (none of the deleted items seems to be my folder). Could you give me some hint of what might have happened at low level (commands sent by kmail to the imap server, and maybe system calls (unlink, rename,...) executed by the imap server)? Were the files unlinked()? Or were they moved to a non-obvious place (if so, which one?). At least, the names of the files seems to have changed, as find didn't turn anything up... Is there any possibility to roll back at this point, or are these folders permanently lost?

Can you recommend another imap server which does not have this issue, so as to avoid similar problems in the future?

Thanks
Comment 3 Carsten Burghardt 2005-06-27 22:21:26 UTC
> ------- Still, shouldn't there be a very obvious warning in such a
> situation (such as "Your IMAP server is broken. If you chose to procede
> anyways, data loss may occur". There is no way a normal user would know
> that choosing Subfolder will destroy the folder rather than moving it.


I thought that a question "do you want to store emails _or_ subfolders in your 
new folder" is self-explanining. Nevertheless a solution might be to override 
the creation and choose "store emails" in this case. But it's not that easy.

> Is there any
> possibility to roll back at this point, or are these folders permanently
> lost?


They are probably lost, I'm afraid.

> Can you recommend another imap server which does not have this issue, so as
> to avoid similar problems in the future?


Any other server should be ok, such as courier or cyrus (preferred).
Comment 4 Alain Knaff 2005-06-27 23:23:56 UTC
>I thought that a question "do you want to store emails _or_ subfolders in your new folder" is self-explanining.

Sorry, no, it is not. To somebody unfamiliar with the internals of kmail, it is not clear at all that one of the choices will lose data! Choices that have the potential of damaging data should explicitly say so.

And then, it's not actually a "new" folder either, it's supposed to be an _existing_ folder with a new name. Or is renaming internally implemented as copy+delete? In that case, shouldn't the command really test whether the copy actually succeeded before proceeding to the delete stage? The Unix command mv also does copy+delete if you try to "move" files across filesystems. However, if for some reason the copy phase fails (permissions, whatever), the delete is not performed!

> Nevertheless a solution might be to override the creation and choose "store emails" in this case. But it's not that easy. 

Emm, if it is not "that easy" to implement the feature in a safe way, why implement it at all? As it is, the Move Folder feature is just a disaster waiting to happen!

> They are probably lost, I'm afraid.

:-(

> Any other server should be ok, such as courier or cyrus (preferred).

AFAIK, cyrus relies on a proprietary folder format (stored in a database?), so is obviously not an option.

I'll check out courier.
Comment 5 Gareth Davies 2005-11-06 23:08:07 UTC
Similar problem with Courier-IMAP: move a local folder to a remote server, and all the folder contents, sub-folders, and contents of sub-folders are lost.

This should never be the result of what is a conceptually simple 'move', especially without warning the user that such an action will lead to all the emails stored in the folder hierarchy being deleted.

In fact, I would go so far as to say that if a folder hierarchy cannot be moved properly, the option should not be offered.
Comment 6 Thomas McGuire 2007-05-08 16:39:30 UTC
Raising severity due to mail loss.
Comment 7 Björn Ruberg 2009-12-21 15:52:05 UTC
Can this be fixed?
Comment 8 Laurent Montel 2015-04-12 10:11:37 UTC
Thank you for taking the time to file a bug report.

KMail2 was released in 2011, and the entire code base went through significant changes. We are currently in the process of porting to Qt5 and KF5. It is unlikely that these bugs are still valid in KMail2.

We welcome you to try out KMail 2 with the KDE 4.14 release and give your feedback.