119515 r=bienvenu sr=mscott. fix local move/copy messages failures

This commit is contained in:
naving%netscape.com 2002-01-24 21:49:15 +00:00
parent 148a6b34f1
commit 32410728ad
4 changed files with 42 additions and 7 deletions

View File

@ -56,5 +56,5 @@ interface nsICopyMessageListener : nsISupports
void copyData(in nsIInputStream aIStream, in long aLength);
void endMessage(in nsMsgKey key);
void endCopy(in boolean copySucceeded);
void endMove();
void endMove(in boolean moveSucceeded);
};

View File

@ -156,7 +156,7 @@ NS_IMETHODIMP nsCopyMessageStreamListener::EndCopy(nsISupports *url, nsresult aS
PRBool copySucceeded = (aStatus == NS_BINDING_SUCCEEDED);
rv = mDestination->EndCopy(copySucceeded);
//If this is a move and we finished the copy, delete the old message.
if(NS_SUCCEEDED(rv) && copySucceeded)
if(NS_SUCCEEDED(rv))
{
PRBool moveMessage = PR_FALSE;
@ -179,7 +179,7 @@ NS_IMETHODIMP nsCopyMessageStreamListener::EndCopy(nsISupports *url, nsresult aS
// if the destination is a local folder, it will handle the delete from the source in EndMove
// rv = DeleteMessage(uri, mSrcFolder);
// if(NS_SUCCEEDED(rv))
rv = mDestination->EndMove();
rv = mDestination->EndMove(copySucceeded);
}
}
}

View File

@ -2717,7 +2717,7 @@ NS_IMETHODIMP nsImapMailFolder::EndCopy(PRBool copySucceeded)
return rv;
}
NS_IMETHODIMP nsImapMailFolder::EndMove()
NS_IMETHODIMP nsImapMailFolder::EndMove(PRBool moveSucceeded)
{
return NS_OK;
}

View File

@ -127,6 +127,7 @@ nsLocalMailCopyState::~nsLocalMailCopyState()
{
if (m_fileStream)
{
if (m_fileStream->is_open())
m_fileStream->close();
delete m_fileStream;
}
@ -2447,11 +2448,27 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndCopy(PRBool copySucceeded)
{
if (mCopyState->m_fileStream)
mCopyState->m_fileStream->close();
if (mDatabase)
mDatabase->EndBatch(); //will close the stream so that truncation is successful.
nsCOMPtr <nsIFileSpec> pathSpec;
rv = GetPath(getter_AddRefs(pathSpec));
if (NS_SUCCEEDED(rv) && pathSpec)
pathSpec->Truncate(mCopyState->m_curDstKey);
ClearCopyState(PR_FALSE);
if (!mCopyState->m_isMove)
{
/*passing PR_TRUE because the messages that have been successfully copied have their corressponding
hdrs in place. The message that has failed has been truncated so the msf file and berkeley mailbox
are in sync*/
ClearCopyState(PR_TRUE);
// enable the dest folder
EnableNotifications(allMessageCountNotifications, PR_TRUE);
}
return NS_OK;
}
@ -2613,10 +2630,28 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndCopy(PRBool copySucceeded)
return rv;
}
NS_IMETHODIMP nsMsgLocalMailFolder::EndMove()
NS_IMETHODIMP nsMsgLocalMailFolder::EndMove(PRBool moveSucceeded)
{
nsresult result;
if (!moveSucceeded && mCopyState)
{
//Notify that a completion finished.
nsCOMPtr<nsIMsgFolder> srcFolder = do_QueryInterface(mCopyState->m_srcSupport);
srcFolder->EnableNotifications(allMessageCountNotifications, PR_TRUE);
srcFolder->NotifyFolderEvent(mDeleteOrMoveMsgFailedAtom);
/*passing PR_TRUE because the messages that have been successfully copied have their corressponding
hdrs in place. The message that has failed has been truncated so the msf file and berkeley mailbox
are in sync*/
ClearCopyState(PR_TRUE);
// enable the dest folder
EnableNotifications(allMessageCountNotifications, PR_TRUE);
return NS_OK;
}
if (mCopyState && mCopyState->m_curCopyIndex >= mCopyState->m_totalMsgCount)
{