From 43c32c28242eee9acaf12538379273c729a30f46 Mon Sep 17 00:00:00 2001 From: "naving%netscape.com" Date: Wed, 12 Dec 2001 01:47:24 +0000 Subject: [PATCH] 113397 r=bienvenu sr=mscott. reduce the cache size once the folder has been loaded. --- .../resources/content/msgMail3PaneWindow.js | 19 ++++++------------- mailnews/db/msgdb/public/nsIMsgDatabase.idl | 1 + mailnews/db/msgdb/src/nsMsgDatabase.cpp | 12 +++++++++++- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/mailnews/base/resources/content/msgMail3PaneWindow.js b/mailnews/base/resources/content/msgMail3PaneWindow.js index 2ba3faa2844..db97e5ea188 100644 --- a/mailnews/base/resources/content/msgMail3PaneWindow.js +++ b/mailnews/base/resources/content/msgMail3PaneWindow.js @@ -56,6 +56,7 @@ var gHaveLoadedMessage; var gDisplayStartupPage = false; + // the folderListener object var folderListener = { OnItemAdded: function(parentItem, item, view) { }, @@ -103,7 +104,6 @@ var folderListener = { var msgFolder = folder.QueryInterface(Components.interfaces.nsIMsgFolder); if(msgFolder) { msgFolder.endFolderLoading(); - // suppress command updating when rerooting the folder // when rerooting, we'll be clearing the selection // which will cause us to update commands. @@ -112,6 +112,10 @@ var folderListener = { } if (gRerootOnFolderLoad) RerootFolder(uri, msgFolder, gCurrentLoadingFolderViewType, gCurrentLoadingFolderViewFlags, gCurrentLoadingFolderSortType, gCurrentLoadingFolderSortOrder); + + var db = msgFolder.getMsgDatabase(msgWindow); + if (db) + db.resetHdrCacheSize(100); if (gDBView) { gDBView.suppressCommandUpdating = false; @@ -560,18 +564,7 @@ function loadStartFolder(initialUri) { // Perform biff on the server to check for new mail, except for imap if (defaultServer.type != "imap") - { - var localFolder = inboxFolder.QueryInterface(Components.interfaces.nsIMsgLocalMailFolder); - if (localFolder) - { - if (!localFolder.parsingInbox) - defaultServer.PerformBiff(); - else - localFolder.checkForNewMessagesAfterParsing = true; - } - else //it can be only nntp - defaultServer.PerformBiff(); - } + defaultServer.PerformBiff(); } // because the "open" state persists, we'll call diff --git a/mailnews/db/msgdb/public/nsIMsgDatabase.idl b/mailnews/db/msgdb/public/nsIMsgDatabase.idl index 3e434453cff..c905f9f3b6f 100644 --- a/mailnews/db/msgdb/public/nsIMsgDatabase.idl +++ b/mailnews/db/msgdb/public/nsIMsgDatabase.idl @@ -117,6 +117,7 @@ interface nsIMsgDatabase : nsIDBChangeAnnouncer { // In 4.x, it was mainly used to remove corrupted databases. void ForceClosed(); void clearCachedHdrs(); + void resetHdrCacheSize(in unsigned long size); readonly attribute nsIDBFolderInfo dBFolderInfo; diff --git a/mailnews/db/msgdb/src/nsMsgDatabase.cpp b/mailnews/db/msgdb/src/nsMsgDatabase.cpp index d87f8611330..8792d2868a8 100644 --- a/mailnews/db/msgdb/src/nsMsgDatabase.cpp +++ b/mailnews/db/msgdb/src/nsMsgDatabase.cpp @@ -95,7 +95,7 @@ static NS_DEFINE_CID(kMsgHeaderParserCID, NS_MSGHEADERPARSER_CID); #define MSG_HASH_SIZE 512 -const PRInt32 kMaxHdrsInCache = 512; // this will be used on discovery, since we don't know total, and after loading (and sorting), on a new header, we'll use this. +const PRInt32 kMaxHdrsInCache = 512; // this will be used on discovery, since we don't know total // special keys static const nsMsgKey kAllMsgHdrsTableKey = 1; @@ -4260,3 +4260,13 @@ NS_IMETHODIMP nsMsgDatabase::GetDefaultSortType(nsMsgViewSortTypeValue *aDefault *aDefaultSortType = nsMsgViewSortType::byDate; return NS_OK; } + +NS_IMETHODIMP nsMsgDatabase::ResetHdrCacheSize(PRUint32 aSize) +{ + if (m_cacheSize > aSize) + { + m_cacheSize = aSize; + ClearHdrCache(PR_FALSE); + } + return NS_OK; +}