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/imap/src/nsImapMailFolder.cpp | 54 ++++++++-------------------------- 1 file changed, 13 insertions(+), 41 deletions(-) (limited to 'mailnews/imap/src/nsImapMailFolder.cpp') diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index df222cb85..4fade9d3f 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -1468,7 +1468,6 @@ NS_IMETHODIMP nsImapMailFolder::EmptyTrash(nsIMsgWindow *aMsgWindow, nsIUrlListe } // if we fetched an imap server } // if emptying trash on exit which is done through the account manager. - nsCOMPtr trashDB; if (WeAreOffline()) { nsCOMPtr trashDB; @@ -1485,12 +1484,7 @@ NS_IMETHODIMP nsImapMailFolder::EmptyTrash(nsIMsgWindow *aMsgWindow, nsIUrlListe } return rv; } - nsCOMPtr transferInfo; - rv = trashFolder->GetDBTransferInfo(getter_AddRefs(transferInfo)); - rv = trashFolder->Delete(); // delete summary spec - trashFolder->SetDBTransferInfo(transferInfo); - trashFolder->SetSizeOnDisk(0); nsCOMPtr imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); @@ -1536,7 +1530,17 @@ NS_IMETHODIMP nsImapMailFolder::EmptyTrash(nsIMsgWindow *aMsgWindow, nsIUrlListe } } - // The trash folder has effectively been deleted + nsCOMPtr transferInfo; + rv = trashFolder->GetDBTransferInfo(getter_AddRefs(transferInfo)); + NS_ENSURE_SUCCESS(rv, rv); + // Bulk-delete all the messages by deleting the msf file and storage. + // This is a little kludgy. + rv = trashFolder->Delete(); + NS_ENSURE_SUCCESS(rv, rv); + trashFolder->SetDBTransferInfo(transferInfo); + trashFolder->SetSizeOnDisk(0); + + // The trash folder has effectively been deleted. nsCOMPtr notifier(do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID)); if (notifier) notifier->NotifyFolderDeleted(trashFolder); @@ -1548,41 +1552,9 @@ NS_IMETHODIMP nsImapMailFolder::EmptyTrash(nsIMsgWindow *aMsgWindow, nsIUrlListe NS_IMETHODIMP nsImapMailFolder::Delete() { - nsresult rv; - if (!mDatabase) - { - // Check if anyone has this db open. If so, do a force closed. - nsCOMPtr msgDBService = do_GetService(NS_MSGDB_SERVICE_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - msgDBService->CachedDBForFolder(this, getter_AddRefs(mDatabase)); - } - if (mDatabase) - { - mDatabase->ForceClosed(); - mDatabase = nullptr; - } + nsresult rv = nsMsgDBFolder::Delete(); - nsCOMPtr path; - rv = GetFilePath(getter_AddRefs(path)); - if (NS_SUCCEEDED(rv)) - { - nsCOMPtr summaryLocation; - rv = GetSummaryFileLocation(path, getter_AddRefs(summaryLocation)); - if (NS_SUCCEEDED(rv)) - { - bool exists = false; - rv = summaryLocation->Exists(&exists); - if (NS_SUCCEEDED(rv) && exists) - { - rv = summaryLocation->Remove(false); - if (NS_FAILED(rv)) - NS_WARNING("failed to remove imap summary file"); - } - } - } - if (mPath) - mPath->Remove(false); - // should notify nsIMsgFolderListeners about the folder getting deleted... + // Should notify nsIMsgFolderListeners about the folder getting deleted? return rv; } -- cgit v1.2.3