Bug 140195 - deleting maildir does not delete associated .index.ids file
Summary: deleting maildir does not delete associated .index.ids file
Status: RESOLVED FIXED
Alias: None
Product: kmail
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
: 145885 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-01-17 16:54 UTC by CSights
Modified: 2007-05-24 17:09 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
proposed fix (433 bytes, patch)
2007-03-05 14:42 UTC, CSights
Details

Note You need to log in before you can comment on or make changes to this bug.
Description CSights 2007-01-17 16:54:14 UTC
Version:           unknown (using KDE 3.5.5, Debian Package 4:3.5.5a.dfsg.1-5 (4.0))
Compiler:          Target: i486-linux-gnu
OS:                Linux (i686) release 2.6.19.2

Hello,
   Deleting a folder in the Local Folders leaves behind it's associated .index.ids file in the file system.

E.g. create and delete "tester" in the Local Folders.  The file tester.index.ids remains on the file system.

Thanks for your hard work!

C.
Comment 1 CSights 2007-02-02 18:42:25 UTC
Hi again,
	It appears as though the .index.ids files are deleted when the 
folder is deleted, but then erroneously created again later in the 
delete process.
	I haven't figured out exactly what is going on, but it looks like
"FolderStorage::remove" calls "KMMsgDict::removeFolderIds" which succeeds.
	Later (I'm not sure how or why) "FolderStorage::deregisterFromMessageDict"
is called and that causes the .index.ids to be created again.
	Hopefully someone with more skills can figure the rest of this out!

Thanks,
	C.

---------------------------------------------------------------------------------
output of fileschanged
---------------------------------------------------------------------------------

fileschanged -rp -s created,deleted kmail/

	( click on Local Folders )
	( New folder "messykmail" )
A /home/csights/.kde3.5/share/apps/kmail/mail/messykmail
A /home/csights/.kde3.5/share/apps/kmail/mail/.messykmail.index
R /home/csights/.kde3.5/share/apps/kmail/mail/.messykmail.index.temp
A /home/csights/.kde3.5/share/apps/kmail/mail/.messykmail.index
A /home/csights/.kde3.5/share/apps/kmail/mail/.messykmail.index.ids

	( delete "messykmail" )
(.ids deleted >>>>>)
R /home/csights/.kde3.5/share/apps/kmail/mail/.messykmail.index.ids
R /home/csights/.kde3.5/share/apps/kmail/mail/.messykmail.index
R /home/csights/.kde3.5/share/apps/kmail/mail/messykmail/new
R /home/csights/.kde3.5/share/apps/kmail/mail/messykmail/cur
R /home/csights/.kde3.5/share/apps/kmail/mail/messykmail/tmp
R /home/csights/.kde3.5/share/apps/kmail/mail/messykmail
R /home/csights/.kde3.5/share/apps/kmail/mail/messykmail
(.ids recreated >>>>>)
A /home/csights/.kde3.5/share/apps/kmail/mail/.messykmail.index.ids


---------------------------------------------------------------------------------
some crappy tracing of the functions
---------------------------------------------------------------------------------

	( New folder "messykmail" )
kmail: WARNING: FolderStorage::writeFolderIdsFile
kmail: WARNING: KMMsgDict::readFolderIds
kmail: WARNING: KMMsgDict::isFolderIdsOutdated
kmail: WARNING: KMMsgDict::readFolderIds - 1st return
kmail: WARNING: FolderStorage::invalidateFolder
kmail: WARNING: KMMsgDict::writeFolderIds
kmail: WARNING: KMMsgDict::openFolderIds - top
kmail: WARNING: KMMsgDict::openFolderIds - opened /home/csights/.kde3.5/share/apps/kmail/mail/.messykmail.index.ids
kmail: WARNING: KMMsgDict::openFolderIds - 2nd return (rentry)
kmail: WARNING: KMMsgDict::writeFolderIds: truncate file /home/csights/.kde3.5/share/apps/kmail/mail/.messykmail.index.ids
kmail: WARNING: KMMsgDict::writeFolderIds - closing /home/csights/.kde3.5/share/apps/kmail/mail/.messykmail.index.ids
kmail: WARNING: KMMsgDict::writeFolderIds - 4th return


	( delete "messykmail" )
kmail: WARNING: FolderStorage::remove()
kmail: WARNING: KMMsgDict::touchFolderIds
kmail: WARNING: KMMsgDict::openFolderIds - top
kmail: WARNING: KMMsgDict::openFolderIds - opened /home/csights/.kde3.5/share/apps/kmail/mail/.messykmail.index.ids
kmail: WARNING: KMMsgDict::openFolderIds - 2nd return (rentry)
kmail: WARNING: KMMsgDict::touchFolderIds - closing /home/csights/.kde3.5/share/apps/kmail/mail/.messykmail.index.ids
kmail: WARNING: KMMsgDict::removeFolderIds - unlinking /home/csights/.kde3.5/share/apps/kmail/mail/.messykmail.index.ids
kmail: WARNING: FolderStorage::remove() unlink .sorted
kmail: WARNING: FolderStorage::remove() unlink folder
kmail: WARNING: KMFolderMgr::removeFolderAux - aFolder -> fileName() messykmail
kmail: WARNING: FolderStorage::deregisterFromMessageDict
kmail: WARNING: FolderStorage::writeFolderIdsFile
kmail: WARNING: KMMsgDict::writeFolderIds
kmail: WARNING: KMMsgDict::openFolderIds - top
kmail: WARNING: KMMsgDict::openFolderIds - opened /home/csights/.kde3.5/share/apps/kmail/mail/.messykmail.index.ids
kmail: WARNING: KMMsgDict::openFolderIds - 2nd return (rentry)
kmail: WARNING: KMMsgDict::writeFolderIds: truncate file /home/csights/.kde3.5/share/apps/kmail/mail/.messykmail.index.ids
kmail: WARNING: KMMsgDict::writeFolderIds - closing /home/csights/.kde3.5/share/apps/kmail/mail/.messykmail.index.ids
kmail: WARNING: KMMsgDict::writeFolderIds - 4th return
kmail: WARNING: KMFolderMgr::removeFolderAux - parentName
kmail: WARNING: Can not find parent folder
--------------------------------------------------------------------
Comment 2 CSights 2007-02-02 22:54:41 UTC
Hi!  I think I've figured this bug out:

	The KMFolder destructor calls
FolderStorage::deregisterFromMessageDict() and this causes the .index.ids
file to be written to disk again after kmail originally deleted it.
	This can be avoided if "mExportsSernums = false;" after the .index.ids
file is deleted in FolderStorage::remove().
	This works because just before writing the .index.ids the code
(FolderStorage::writeFolderIdsFile()) does not write the .index.ids file
if mExportsSernums == false.


folderstorage.cpp
--------------------------------------------------------
void FolderStorage::remove()

   if ( mExportsSernums )
+  {
     KMMsgDict::mutableInstance()->removeFolderIds( *this );
+    mExportsSernums = false;   // do not writeFolderIds after removal
+  }
--------------------------------------------------------

	BTW: I don't know what "int FolderStorage::expunge()" does, but because
the logic is so similar to "FolderStorage::remove()" someone who knows what is
going on might consider modifying it in a similar way.

Thanks!
  C.
Comment 3 Thomas McGuire 2007-03-05 11:19:23 UTC
CSights: The developers of KMail do not monitor the bug database very closly, so they did probably not yet see your patch.

Please do the following to get you patch included:
1. Attach the diff output of folderstorage.cpp to this bug report as a patch so it can be found easily by the bugzilla search function
2. Write a mail to the kde-pim mailinglist or contact the developers at the #kontact IRC channel to get their attention

I am myself not a developer, so I can not comment on the quality of your fix.
Comment 4 CSights 2007-03-05 14:42:40 UTC
Created attachment 19886 [details]
proposed fix

this patch was made from debian's kmail 1.9.5 ( 4:3.5.5.dfsg.1-6 )
Comment 5 Allen Winter 2007-03-06 04:17:59 UTC
SVN commit 639786 by winterz:

fix "deleting maildir does not delete associated .index.ids file"
Thanks for the patch CSights.

BUG: 140195


 M  +3 -1      folderstorage.cpp  


--- branches/KDE/3.5/kdepim/kmail/folderstorage.cpp #639785:639786
@@ -723,8 +723,10 @@
   clearIndex( true, mExportsSernums ); // delete and remove from dict if necessary
   close(true);
 
-  if ( mExportsSernums )
+  if ( mExportsSernums ) {
     KMMsgDict::mutableInstance()->removeFolderIds( *this );
+    mExportsSernums = false;	// do not writeFolderIds after removal
+  }
   unlink(QFile::encodeName(indexLocation()) + ".sorted");
   unlink(QFile::encodeName(indexLocation()));
 
Comment 6 Thomas McGuire 2007-05-24 17:09:16 UTC
*** Bug 145885 has been marked as a duplicate of this bug. ***