From kmail-devel Sat Nov 29 17:43:59 2003 From: Till Adam Date: Sat, 29 Nov 2003 17:43:59 +0000 To: kmail-devel Subject: [Bug 68661] kmail deletes the whole directory if it is existent. X-MARC-Message: https://marc.info/?l=kmail-devel&m=107012788406071 ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. http://bugs.kde.org/show_bug.cgi?id=68661 adam@kde.org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Additional Comments From adam@kde.org 2003-11-29 18:43 ------- Subject: kdepim/kmail CVS commit by tilladam: When the user deletes a maildir folder first delete the new, cur and tmp subdirs, then check if the dir itself is empty and only then delete the folder directory itself. This prevents data loss if the user has non-kmail data stored in a folder in ~/Mail and then creates a maildir folder of the same name and later deletes it. CCMAIL: 68661-done@bugs.kde.org M +16 -3 kmfoldermaildir.cpp 1.72 --- kdepim/kmail/kmfoldermaildir.cpp #1.71:1.72 @@ -887,7 +887,20 @@ bool KMFolderMaildir::removeFile(const Q int KMFolderMaildir::removeContents() { - if (KIO::NetAccess::del(KURL::fromPathOrURL(location()), 0)) - return 0; + if (!KIO::NetAccess::del(KURL::fromPathOrURL(location()+ "/new/"), 0)) + return 1; + if (!KIO::NetAccess::del(KURL::fromPathOrURL(location()+ "/cur/"), 0)) return 1; + if (!KIO::NetAccess::del(KURL::fromPathOrURL(location()+ "/tmp/"), 0)) + return 1; + + /* The subdirs are removed now. Check if there is anything else in the dir + * and only if not delete the dir itself. The user could have data stored + * that would otherwise be deleted. */ + QDir *dir = new QDir(location()); + if ( dir->count() == 2 ) { // only . and .. + if (!KIO::NetAccess::del(KURL::fromPathOrURL(location()), 0)) + return 1; + } + return 0; } _______________________________________________ KMail Developers mailing list kmail@kde.org https://mail.kde.org/mailman/listinfo/kmail