Bug 894012 - convert folder property 'expungedBytes' to int64. r=rkent, r=Neil

This commit is contained in:
aceman 2015-01-30 21:44:26 +01:00
Родитель 9481cd0480
Коммит 5ff96c9397
12 изменённых файлов: 60 добавлений и 46 удалений

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

@ -30,7 +30,7 @@ typedef long nsMsgBiffState;
// enumerated type for determining if a message has been replied to, forwarded, etc.
typedef long nsMsgDispositionState;
[scriptable, uuid(8EC4D122-1082-4fa2-B97C-4AE852B254D2)]
[scriptable, uuid(d277b1d2-e820-42f9-8706-914df7d429b3)]
interface nsIMsgFolder : nsISupports {
const nsMsgBiffState nsMsgBiffState_NewMail = 0; // User has new mail waiting.
@ -266,7 +266,7 @@ interface nsIMsgFolder : nsISupports {
*/
void clearNewMessages();
readonly attribute unsigned long expungedBytes;
readonly attribute long long expungedBytes;
/**
* Can this folder be deleted?

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

@ -167,7 +167,7 @@ nsFolderCompactState::Compact(nsIMsgFolder *folder, bool aOfflineStore,
return imapFolder->Expunge(this, aMsgWindow);
}
uint32_t expunged;
int64_t expunged;
folder->GetExpungedBytes(&expunged);
m_totalExpungedBytes += expunged;
m_window = aMsgWindow;
@ -1084,7 +1084,7 @@ nsOfflineStoreCompactState::FinishCompact()
if (dbFolderInfo)
dbFolderInfo->SetExpungedBytes(0);
// this forces the m_folder to update mExpungedBytes from the db folder info.
uint32_t expungedBytes;
int64_t expungedBytes;
m_folder->GetExpungedBytes(&expungedBytes);
m_folder->UpdateSummaryTotals(true);
m_db->SetSummaryValid(true);

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

@ -386,7 +386,7 @@ NS_IMETHODIMP nsMsgDBFolder::EndFolderLoading(void)
}
NS_IMETHODIMP
nsMsgDBFolder::GetExpungedBytes(uint32_t *count)
nsMsgDBFolder::GetExpungedBytes(int64_t *count)
{
NS_ENSURE_ARG_POINTER(count);
@ -396,7 +396,7 @@ nsMsgDBFolder::GetExpungedBytes(uint32_t *count)
nsCOMPtr<nsIDBFolderInfo> folderInfo;
rv = mDatabase->GetDBFolderInfo(getter_AddRefs(folderInfo));
if (NS_FAILED(rv)) return rv;
rv = folderInfo->GetExpungedBytes((int32_t *) count);
rv = folderInfo->GetExpungedBytes(count);
if (NS_SUCCEEDED(rv))
mExpungedBytes = *count; // sync up with the database
return rv;
@ -668,7 +668,7 @@ nsresult nsMsgDBFolder::ReadDBFolderInfo(bool force)
folderInfo->GetNumMessages(&mNumTotalMessages);
folderInfo->GetNumUnreadMessages(&mNumUnreadMessages);
folderInfo->GetExpungedBytes((int32_t *)&mExpungedBytes);
folderInfo->GetExpungedBytes(&mExpungedBytes);
nsCString utf8Name;
folderInfo->GetFolderName(utf8Name);
@ -1290,7 +1290,7 @@ NS_IMETHODIMP nsMsgDBFolder::ReadFromFolderCacheElem(nsIMsgFolderCacheElement *e
element->GetInt32Property("totalUnreadMsgs", &mNumUnreadMessages);
element->GetInt32Property("pendingUnreadMsgs", &mNumPendingUnreadMessages);
element->GetInt32Property("pendingMsgs", &mNumPendingTotalMessages);
element->GetInt32Property("expungedBytes", (int32_t *) &mExpungedBytes);
element->GetInt64Property("expungedBytes", &mExpungedBytes);
element->GetInt64Property("folderSize", &mFolderSize);
element->GetStringProperty("charset", mCharset);
@ -1413,7 +1413,7 @@ NS_IMETHODIMP nsMsgDBFolder::WriteToFolderCacheElem(nsIMsgFolderCacheElement *el
element->SetInt32Property("totalUnreadMsgs", mNumUnreadMessages);
element->SetInt32Property("pendingUnreadMsgs", mNumPendingUnreadMessages);
element->SetInt32Property("pendingMsgs", mNumPendingTotalMessages);
element->SetInt32Property("expungedBytes", mExpungedBytes);
element->SetInt64Property("expungedBytes", mExpungedBytes);
element->SetInt64Property("folderSize", mFolderSize);
element->SetStringProperty("charset", mCharset);
@ -1841,9 +1841,9 @@ nsresult nsMsgDBFolder::HandleAutoCompactEvent(nsIMsgWindow *aWindow)
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIMutableArray> offlineFolderArray = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
int32_t totalExpungedBytes = 0;
int32_t offlineExpungedBytes = 0;
int32_t localExpungedBytes = 0;
int64_t totalExpungedBytes = 0;
int64_t offlineExpungedBytes = 0;
int64_t localExpungedBytes = 0;
do
{
nsCOMPtr<nsIMsgIncomingServer> server = do_QueryElementAt(allServers, serverIndex, &rv);
@ -1868,7 +1868,7 @@ nsresult nsMsgDBFolder::HandleAutoCompactEvent(nsIMsgWindow *aWindow)
uint32_t cnt = 0;
rv = allDescendents->GetLength(&cnt);
NS_ENSURE_SUCCESS(rv, rv);
uint32_t expungedBytes=0;
int64_t expungedBytes = 0;
if (offlineSupportLevel > 0)
{
uint32_t flags;
@ -1968,7 +1968,7 @@ nsresult nsMsgDBFolder::HandleAutoCompactEvent(nsIMsgWindow *aWindow)
nsCOMPtr <nsIAtom> aboutToCompactAtom = MsgGetAtom("AboutToCompact");
NotifyFolderEvent(aboutToCompactAtom);
if ( localExpungedBytes > 0)
if (localExpungedBytes > 0)
{
nsCOMPtr<nsIMsgFolderCompactor> folderCompactor =
do_CreateInstance(NS_MSGLOCALFOLDERCOMPACTOR_CONTRACTID, &rv);

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

@ -197,7 +197,7 @@ protected:
int32_t mNumUnreadMessages; /* count of unread messages (-1 means unknown; -2 means unknown but we already tried to find out.) */
int32_t mNumTotalMessages; /* count of existing messages. */
bool mNotifyCountChanges;
uint32_t mExpungedBytes;
int64_t mExpungedBytes;
nsCOMArray<nsIMsgFolder> mSubFolders;
// This can't be refcounted due to ownsership issues
nsTObserverArray<nsIFolderListener*> mListeners;

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

@ -50,6 +50,7 @@ public:
// get and set arbitrary property, aka row cell value.
nsresult SetPropertyWithToken(mdb_token aProperty, const nsAString &propertyStr);
nsresult SetUint32PropertyWithToken(mdb_token aProperty, uint32_t propertyValue);
nsresult SetUint64PropertyWithToken(mdb_token aProperty, uint64_t propertyValue);
nsresult SetInt32PropertyWithToken(mdb_token aProperty, int32_t propertyValue);
nsresult GetPropertyWithToken(mdb_token aProperty, nsAString &resultProperty);
nsresult GetUint32PropertyWithToken(mdb_token aProperty, uint32_t &propertyValue, uint32_t defaultValue = 0);
@ -79,8 +80,8 @@ protected:
void ReleaseExternalReferences(); // let go of any references to other objects.
uint64_t m_folderSize;
int32_t m_expungedBytes; // sum of size of deleted messages in folder
uint64_t m_folderSize; // TODO: In nsIMsgFolder folder size is int64_t.
int64_t m_expungedBytes; // sum of size of deleted messages in folder
uint32_t m_folderDate;
nsMsgKey m_highWaterMessageKey; // largest news article number or imap uid whose header we've seen

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

@ -46,7 +46,7 @@ interface nsIDBFolderInfo : nsISupports {
attribute long numUnreadMessages;
attribute long numMessages;
attribute long expungedBytes;
attribute long long expungedBytes;
attribute long imapUidValidity;
attribute unsigned long version;
attribute long imapTotalPendingMessages;

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

@ -359,7 +359,7 @@ nsresult nsDBFolderInfo::LoadMemberVariables()
GetInt32PropertyWithToken(m_folderDateColumnToken, (int32_t &) m_folderDate);
GetInt32PropertyWithToken(m_imapUidValidityColumnToken, m_ImapUidValidity, kUidUnknown);
GetInt32PropertyWithToken(m_expiredMarkColumnToken, (int32_t &) m_expiredMark);
GetInt32PropertyWithToken(m_expungedBytesColumnToken, (int32_t &) m_expungedBytes);
GetUint64PropertyWithToken(m_expungedBytesColumnToken, (uint64_t *) &m_expungedBytes);
GetInt32PropertyWithToken(m_highWaterMessageKeyColumnToken, (int32_t &) m_highWaterMessageKey);
int32_t version;
@ -487,10 +487,10 @@ NS_IMETHODIMP nsDBFolderInfo::GetExpiredMark(nsMsgKey *result)
return NS_OK;
}
NS_IMETHODIMP
nsDBFolderInfo::ChangeExpungedBytes(int32_t delta)
// The size of the argument depends on the maximum size of a single message
NS_IMETHODIMP nsDBFolderInfo::ChangeExpungedBytes(int32_t delta)
{
return SetExpungedBytes(m_expungedBytes + delta);
return SetExpungedBytes(m_expungedBytes + delta);
}
NS_IMETHODIMP nsDBFolderInfo::SetMailboxName(const nsAString &newBoxName)
@ -556,16 +556,16 @@ NS_IMETHODIMP nsDBFolderInfo::SetNumMessages(int32_t numMessages)
return SetUint32PropertyWithToken(m_numMessagesColumnToken, m_numMessages);
}
NS_IMETHODIMP nsDBFolderInfo::GetExpungedBytes(int32_t *result)
NS_IMETHODIMP nsDBFolderInfo::GetExpungedBytes(int64_t *result)
{
*result = m_expungedBytes;
return NS_OK;
}
NS_IMETHODIMP nsDBFolderInfo::SetExpungedBytes(int32_t expungedBytes)
NS_IMETHODIMP nsDBFolderInfo::SetExpungedBytes(int64_t expungedBytes)
{
m_expungedBytes = expungedBytes;
return SetUint32PropertyWithToken(m_expungedBytesColumnToken, m_expungedBytes);
return SetUint64PropertyWithToken(m_expungedBytesColumnToken, m_expungedBytes);
}
@ -832,6 +832,11 @@ nsresult nsDBFolderInfo::SetUint32PropertyWithToken(mdb_token aProperty, uint32
return m_mdb->UInt32ToRowCellColumn(m_mdbRow, aProperty, propertyValue);
}
nsresult nsDBFolderInfo::SetUint64PropertyWithToken(mdb_token aProperty, uint64_t propertyValue)
{
return m_mdb->UInt64ToRowCellColumn(m_mdbRow, aProperty, propertyValue);
}
nsresult nsDBFolderInfo::SetUint64Property(const char *aProperty,
uint64_t propertyValue)
{

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

@ -603,7 +603,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::CompactAll(nsIUrlListener *aListener,
rv = allDescendents->GetLength(&cnt);
NS_ENSURE_SUCCESS(rv, rv);
folderArray = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
uint32_t expungedBytes = 0;
int64_t expungedBytes = 0;
for (uint32_t i = 0; i < cnt; i++)
{
nsCOMPtr<nsIMsgFolder> folder = do_QueryElementAt(allDescendents, i, &rv);

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

@ -803,7 +803,7 @@ NS_IMETHODIMP nsMsgBrkMBoxStore::CompactFolder(nsIMsgFolder *aFolder,
do_CreateInstance(NS_MSGLOCALFOLDERCOMPACTOR_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
uint32_t expungedBytes = 0;
int64_t expungedBytes = 0;
aFolder->GetExpungedBytes(&expungedBytes);
// check if we need to compact the folder
return (expungedBytes > 0) ?

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

@ -293,13 +293,14 @@ function copyIntoOver4GiB()
do_check_true(gGotAlert);
// Make sure inbox file did not grow (i.e., no data were appended).
let newLocalInboxSize = gInbox.filePath.fileSize;
let newLocalInboxSize = gInboxFile.fileSize;
do_print("Local inbox size (after copyFileMessageInLocalFolder()) = " +
newLocalInboxSize);
do_check_eq(newLocalInboxSize, localInboxSize);
// Append a new small message to the folder (+1 MiB).
growInbox(gInboxFile.fileSize + 0x100000);
// Append 2 new small messages to the folder (+1 MiB each).
growInbox(gInboxFile.fileSize + 0x100000); // will be removed in compactOver4GB
growInbox(gInboxFile.fileSize + 0x100000); // will be preserved in CompactUnder4GB
do_check_true(gInboxFile.fileSize > kSizeLimit);
// Force the db closed, so that getDatabaseWithReparse will notice
@ -323,17 +324,18 @@ function compactOver4GiB()
gInboxSize = gInboxFile.fileSize;
do_check_true(gInboxSize > kSizeLimit);
// Delete the last small message at folder end.
let msgDB = gInbox.msgDatabase;
let enumerator = msgDB.EnumerateMessages();
let enumerator = gInbox.messages;
let messages = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
let sizeToExpunge = 0;
while (enumerator.hasMoreElements()) {
let header = enumerator.getNext();
let header = enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr);
if (!enumerator.hasMoreElements()) {
do_check_true(header instanceof Ci.nsIMsgDBHdr);
messages.appendElement(header, false);
sizeToExpunge = header.messageSize;
}
}
gInbox.deleteMessages(messages, null, true, false, null, false);
do_check_eq(gInbox.expungedBytes, sizeToExpunge);
/* Unfortunately, the compaction now would kill the sparse markings in the file
* so it will really take 4GiB of space in the filesystem and may be slow
@ -372,20 +374,25 @@ function compactUnder4GiB()
do_check_eq(gInbox.sizeOnDisk, folderSize);
do_check_eq(gInbox.getTotalMessages(false), totalMsgs);
// Very first header in msgDB is retained,
// then all other headers are marked as deleted.
let msgDB = gInbox.msgDatabase;
let enumerator = msgDB.EnumerateMessages();
let firstHdr = true;
// Very last header in folder is retained,
// but all other preceding headers are marked as deleted.
let enumerator = gInbox.messages;
let messages = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
let sizeToExpunge = gInbox.expungedBytes; // If compact in compactOver4GB was skipped, this is not 0.
while (enumerator.hasMoreElements()) {
let header = enumerator.getNext();
if (header instanceof Ci.nsIMsgDBHdr && !firstHdr)
let header = enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr);
if (enumerator.hasMoreElements()) {
messages.appendElement(header, false);
firstHdr = false;
sizeToExpunge += header.messageSize;
}
}
gInbox.deleteMessages(messages, null, true, false, null, false);
// Bug 894012: size of messages to expunge is now higher than 4GB.
// Only the small 1MiB message remains.
do_check_eq(gInbox.expungedBytes, sizeToExpunge);
do_check_true(sizeToExpunge > kSizeLimit);
// Note: compact() will also add 'X-Mozilla-Status' and 'X-Mozilla-Status2'
// lines to message(s).
gInbox.compact(CompactListener_compactUnder4GiB, null);
@ -429,6 +436,7 @@ var ParseListener_growOver4GiB =
do_check_true(FListener.sizeHistory(1) < FListener.sizeHistory(0));
do_check_eq(FListener.msgsHistory(0),
FListener.msgsHistory(1) + gExpectedNewMessages);
do_check_eq(gInbox.expungedBytes, 0);
copyIntoOver4GiB();
}
@ -490,7 +498,7 @@ var CompactListener_compactUnder4GiB =
function endTest()
{
MailServices.mailSession.RemoveFolderListener(FListener);
MailServices.mailSession.RemoveFolderListener(FListener);
// Free up disk space - if you want to look at the file after running
// this test, comment out this line.
gInbox.filePath.remove(false);

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

@ -729,7 +729,7 @@ nsMsgNewsFolder::UpdateSummaryFromNNTPInfo(int32_t oldest, int32_t youngest, int
return NS_OK;
}
NS_IMETHODIMP nsMsgNewsFolder::GetExpungedBytesCount(uint32_t *count)
NS_IMETHODIMP nsMsgNewsFolder::GetExpungedBytesCount(int64_t *count)
{
NS_ENSURE_ARG_POINTER(count);
*count = mExpungedBytes;

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

@ -48,7 +48,7 @@ public:
NS_IMETHOD GetFolderURL(nsACString& url) MOZ_OVERRIDE;
NS_IMETHOD GetExpungedBytesCount(uint32_t *count);
NS_IMETHOD GetExpungedBytesCount(int64_t *count);
NS_IMETHOD GetDeletable(bool *deletable) MOZ_OVERRIDE;
NS_IMETHOD RefreshSizeOnDisk();
@ -116,7 +116,7 @@ protected:
virtual nsresult CreateBaseMessageURI(const nsACString& aURI) MOZ_OVERRIDE;
protected:
uint32_t mExpungedBytes;
int64_t mExpungedBytes;
bool mGettingNews;
bool mInitialized;
bool m_downloadMessageForOfflineUse;