diff options
author | Matt A. Tobin <email@mattatobin.com> | 2019-11-10 20:27:19 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2019-11-10 20:27:19 -0500 |
commit | 1f5f6a4bf0163f4dcf0fd6778611891165c334ff (patch) | |
tree | b4211330b96a89b66c838c116dbc379159c62ed6 /mailnews/imap/src/nsImapMailFolder.cpp | |
parent | 4d20783c0aa26ced30b55c3eaaab76f46a01a803 (diff) | |
download | UXP-1f5f6a4bf0163f4dcf0fd6778611891165c334ff.tar UXP-1f5f6a4bf0163f4dcf0fd6778611891165c334ff.tar.gz UXP-1f5f6a4bf0163f4dcf0fd6778611891165c334ff.tar.lz UXP-1f5f6a4bf0163f4dcf0fd6778611891165c334ff.tar.xz UXP-1f5f6a4bf0163f4dcf0fd6778611891165c334ff.zip |
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
Diffstat (limited to 'mailnews/imap/src/nsImapMailFolder.cpp')
-rw-r--r-- | mailnews/imap/src/nsImapMailFolder.cpp | 54 |
1 files changed, 13 insertions, 41 deletions
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<nsIMsgDatabase> trashDB; if (WeAreOffline()) { nsCOMPtr <nsIMsgDatabase> trashDB; @@ -1485,12 +1484,7 @@ NS_IMETHODIMP nsImapMailFolder::EmptyTrash(nsIMsgWindow *aMsgWindow, nsIUrlListe } return rv; } - nsCOMPtr <nsIDBFolderInfo> transferInfo; - rv = trashFolder->GetDBTransferInfo(getter_AddRefs(transferInfo)); - rv = trashFolder->Delete(); // delete summary spec - trashFolder->SetDBTransferInfo(transferInfo); - trashFolder->SetSizeOnDisk(0); nsCOMPtr<nsIImapService> 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 <nsIDBFolderInfo> 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<nsIMsgFolderNotificationService> 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<nsIMsgDBService> 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<nsIFile> path; - rv = GetFilePath(getter_AddRefs(path)); - if (NS_SUCCEEDED(rv)) - { - nsCOMPtr<nsIFile> 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; } |