fix memory bloat when compacting all folders by closing db after folder is compacted, r/a=sspitzer, sr=mscott 228383

This commit is contained in:
bienvenu%nventure.com 2003-12-15 23:31:25 +00:00
Родитель c98b299b45
Коммит f86268c768
3 изменённых файлов: 24 добавлений и 21 удалений

Просмотреть файл

@ -1026,8 +1026,8 @@ NS_IMETHODIMP nsMsgDBFolder::ReadFromFolderCacheElem(nsIMsgFolderCacheElement *e
mFlags |= MSG_FOLDER_FLAG_ELIDED;
}
element->GetInt32Property("totalMsgs", &mNumTotalMessages);
element->GetInt32Property("totalUnreadMsgs", &mNumUnreadMessages);
element->GetInt32Property("totalMsgs", &mNumTotalMessages);
element->GetInt32Property("totalUnreadMsgs", &mNumUnreadMessages);
element->GetInt32Property("pendingUnreadMsgs", &mNumPendingUnreadMessages);
element->GetInt32Property("pendingMsgs", &mNumPendingTotalMessages);
element->GetInt32Property("expungedBytes", (PRInt32 *) &mExpungedBytes);
@ -1211,8 +1211,6 @@ nsMsgDBFolder::MarkAllMessagesRead(void)
EnableNotifications(allMessageCountNotifications, PR_FALSE, PR_TRUE /*dbBatching*/);
rv = mDatabase->MarkAllRead(nsnull);
EnableNotifications(allMessageCountNotifications, PR_TRUE, PR_TRUE /*dbBatching*/);
mDatabase->SetSummaryValid(PR_TRUE);
mDatabase->Commit(nsMsgDBCommitType::kLargeCommit);
}
return rv;
}
@ -3154,6 +3152,7 @@ void nsMsgDBFolder::ChangeNumPendingUnread(PRInt32 delta)
PRInt32 oldUnreadMessages = mNumUnreadMessages + mNumPendingUnreadMessages;
mNumPendingUnreadMessages += delta;
PRInt32 newUnreadMessages = mNumUnreadMessages + mNumPendingUnreadMessages;
NS_ASSERTION(newUnreadMessages >= 0, "shouldn't have negative unread message count");
nsCOMPtr<nsIMsgDatabase> db;
nsCOMPtr<nsIDBFolderInfo> folderInfo;
nsresult rv = GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), getter_AddRefs(db));
@ -4389,6 +4388,21 @@ NS_IMETHODIMP nsMsgDBFolder::NotifyCompactCompleted()
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult nsMsgDBFolder::CloseDBIfFolderNotOpen()
{
nsresult rv;
nsCOMPtr<nsIMsgMailSession> session =
do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && session) // don't use NS_ENSURE_SUCCESS here - we need to release semaphore below
{
PRBool folderOpen;
session->IsFolderOpenInWindow(this, &folderOpen);
if (!folderOpen && ! (mFlags & (MSG_FOLDER_FLAG_TRASH | MSG_FOLDER_FLAG_INBOX)))
SetMsgDatabase(nsnull);
}
return rv;
}
NS_IMETHODIMP nsMsgDBFolder::SetSortOrder(PRInt32 order)
{
NS_ASSERTION(PR_FALSE, "not implemented");

Просмотреть файл

@ -146,6 +146,7 @@ protected:
nsresult GetPurgeThreshold(PRInt32 *aThreshold);
nsresult PerformBiffNotifications(void); // if there are new, non spam messages, do biff
nsresult CloseDBIfFolderNotOpen();
virtual nsresult SpamFilterClassifyMessage(const char *aURI, nsIMsgWindow *aMsgWindow, nsIJunkMailPlugin *aJunkMailPlugin);
virtual nsresult SpamFilterClassifyMessages(const char **aURIArray, PRUint32 aURICount, nsIMsgWindow *aMsgWindow, nsIJunkMailPlugin *aJunkMailPlugin);

Просмотреть файл

@ -801,6 +801,7 @@ nsresult nsMsgLocalMailFolder::CreateDirectoryForFolder(nsFileSpec &path)
//otherwise we need to create a new directory.
else
{
nsFileSpec tempPath(path.GetNativePathCString(), PR_TRUE); // create intermediate directories
path.CreateDirectory();
//Above doesn't return an error value so let's see if
//it was created.
@ -1624,14 +1625,9 @@ nsMsgLocalMailFolder::DeleteMessages(nsISupportsArray *messages,
ThrowAlertMsg("deletingMsgsFailed", msgWindow);
// we are the source folder here for a move or shift delete
//enable notifications first, because that will close the file stream
// we've been caching, and truly make the summary valid.
//enable notifications because that will close the file stream
// we've been caching, mark the db as valid, and commit it.
EnableNotifications(allMessageCountNotifications, PR_TRUE, PR_TRUE /*dbBatching*/);
if (NS_SUCCEEDED(rv))
{
mDatabase->SetSummaryValid(PR_TRUE);
mDatabase->Commit(nsMsgDBCommitType::kLargeCommit);
}
if(!isMove)
NotifyFolderEvent(NS_SUCCEEDED(rv) ? mDeleteOrMoveMsgCompletedAtom : mDeleteOrMoveMsgFailedAtom);
}
@ -1727,16 +1723,7 @@ nsMsgLocalMailFolder::OnCopyCompleted(nsISupports *srcSupport, PRBool moveCopySu
{
mDatabase->SetSummaryValid(PR_TRUE);
mDatabase->Commit(nsMsgDBCommitType::kLargeCommit);
nsresult rv;
nsCOMPtr<nsIMsgMailSession> session =
do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && session) // don't use NS_ENSURE_SUCCESS here - we need to release semaphore below
{
PRBool folderOpen;
session->IsFolderOpenInWindow(this, &folderOpen);
if (!folderOpen && ! (mFlags & (MSG_FOLDER_FLAG_TRASH | MSG_FOLDER_FLAG_INBOX)))
SetMsgDatabase(nsnull);
}
(void) CloseDBIfFolderNotOpen();
}
PRBool haveSemaphore;
@ -3390,6 +3377,7 @@ NS_IMETHODIMP
nsMsgLocalMailFolder::NotifyCompactCompleted()
{
(void) RefreshSizeOnDisk();
(void) CloseDBIfFolderNotOpen();
nsCOMPtr <nsIAtom> compactCompletedAtom;
compactCompletedAtom = do_GetAtom("CompactCompleted");
NotifyFolderEvent(compactCompletedAtom);