From 1f5f6a4bf0163f4dcf0fd6778611891165c334ff Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sun, 10 Nov 2019 20:27:19 -0500 Subject: Bug 1317117 - call msgStore folder deletion during imap/news empty trash. Also factors out some common code into nsMSgDBFolder::Delete(), and makes a couple of incidental changes to try and clarify the responsibilies of nsIMsgPluggableStore::DeleteFolder(). Tag #1273 --- mailnews/base/public/nsIMsgPluggableStore.idl | 4 ++-- mailnews/base/util/nsMsgDBFolder.cpp | 26 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) (limited to 'mailnews/base') diff --git a/mailnews/base/public/nsIMsgPluggableStore.idl b/mailnews/base/public/nsIMsgPluggableStore.idl index 18415d801..12713b236 100644 --- a/mailnews/base/public/nsIMsgPluggableStore.idl +++ b/mailnews/base/public/nsIMsgPluggableStore.idl @@ -51,8 +51,8 @@ interface nsIMsgPluggableStore : nsISupports { nsIMsgFolder createFolder(in nsIMsgFolder aParent, in AString aFolderName); /** - * Delete the passed in folder. This is a real delete, not a move - * to the trash folder. + * Delete storage for a folder and its subfolders, if any. + * This is a real delete, not a move to the trash folder. * * @param aFolder folder to delete */ diff --git a/mailnews/base/util/nsMsgDBFolder.cpp b/mailnews/base/util/nsMsgDBFolder.cpp index 81790c69a..c6356f83d 100644 --- a/mailnews/base/util/nsMsgDBFolder.cpp +++ b/mailnews/base/util/nsMsgDBFolder.cpp @@ -3559,7 +3559,31 @@ NS_IMETHODIMP nsMsgDBFolder::GetShowDeletedMessages(bool *showDeletedMessages) NS_IMETHODIMP nsMsgDBFolder::Delete() { - return NS_OK; + ForceDBClosed(); + + // Delete the .msf file. + // NOTE: this doesn't remove .msf files in subfolders, but + // both nsMsgBrkMBoxStore::DeleteFolder() and + // nsMsgMaildirStore::DeleteFolder() will remove those .msf files + // as a side-effect of deleting the .sbd directory. + nsCOMPtr summaryFile; + nsresult rv = GetSummaryFile(getter_AddRefs(summaryFile)); + NS_ENSURE_SUCCESS(rv, rv); + bool exists = false; + summaryFile->Exists(&exists); + if (exists) { + rv = summaryFile->Remove(false); + NS_ENSURE_SUCCESS(rv, rv); + } + + // Ask the msgStore to delete the actual storage (mbox, maildir or whatever + // else may be supported in future). + nsCOMPtr msgStore; + rv = GetMsgStore(getter_AddRefs(msgStore)); + NS_ENSURE_SUCCESS(rv, rv); + rv = msgStore->DeleteFolder(this); + + return rv; } NS_IMETHODIMP nsMsgDBFolder::DeleteSubFolders(nsIArray *folders, -- cgit v1.2.3