fix 470011 playback of offline imap move/copies need to check if dest folder exists, r/sr=standard8

This commit is contained in:
David Bienvenu 2008-12-30 09:23:16 -08:00
Родитель ba25051d80
Коммит 3ffa2fbfb7
2 изменённых файлов: 87 добавлений и 86 удалений

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

@ -121,13 +121,7 @@ nsImapOfflineSync::OnStopRunningUrl(nsIURI* url, nsresult exitCode)
// should allow us to continue.
if (NS_SUCCEEDED(exitCode))
{
PRInt32 opCount = m_currentOpsToClear.Count();
for (PRInt32 i = 0; i < opCount; i++)
{
m_currentOpsToClear[i]->SetPlayingBack(PR_FALSE);
m_currentOpsToClear[i]->ClearOperation(mCurrentPlaybackOpType);
}
ClearCurrentOps();
rv = ProcessNextOperation();
}
// else if it's a non-stop error, and we're doing multiple folders,
@ -483,6 +477,15 @@ nsImapOfflineSync::ProcessAppendMsgOperation(nsIMsgOfflineImapOperation *current
}
}
void nsImapOfflineSync::ClearCurrentOps()
{
PRInt32 opCount = m_currentOpsToClear.Count();
for (PRInt32 i = 0; i < opCount; i++)
{
m_currentOpsToClear[i]->SetPlayingBack(PR_FALSE);
m_currentOpsToClear[i]->ClearOperation(mCurrentPlaybackOpType);
}
}
void nsImapOfflineSync::ProcessMoveOperation(nsIMsgOfflineImapOperation *op)
{
@ -523,25 +526,26 @@ void nsImapOfflineSync::ProcessMoveOperation(nsIMsgOfflineImapOperation *op)
}
while (currentOp);
nsresult rv;
nsCOMPtr<nsIRDFResource> res;
nsCOMPtr<nsIRDFService> rdf(do_GetService(kRDFServiceCID, &rv));
if (NS_FAILED(rv)) return ; // ### return error code.
rv = rdf->GetResource(moveDestination, getter_AddRefs(res));
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIMsgFolder> destFolder(do_QueryInterface(res, &rv));
if (NS_SUCCEEDED(rv) && destFolder)
nsCOMPtr<nsIMsgFolder> destFolder;
GetExistingFolder(moveDestination, getter_AddRefs(destFolder));
// if the dest folder doesn't really exist, these operations are
// going to fail, so clear them out and move on.
if (!destFolder)
{
NS_ERROR("trying to playing back move to non-existent folder");
ClearCurrentOps();
ProcessNextOperation();
return;
}
nsCOMPtr<nsIMsgImapMailFolder> imapFolder = do_QueryInterface(m_currentFolder);
if (imapFolder && DestFolderOnSameServer(destFolder))
{
rv = imapFolder->ReplayOfflineMoveCopy(matchingFlagKeys.Elements(), matchingFlagKeys.Length(), PR_TRUE, destFolder,
imapFolder->ReplayOfflineMoveCopy(matchingFlagKeys.Elements(), matchingFlagKeys.Length(), PR_TRUE, destFolder,
this, m_window);
}
else
{
nsresult rv;
nsCOMPtr<nsIMutableArray> messages(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv))
{
@ -578,8 +582,6 @@ void nsImapOfflineSync::ProcessMoveOperation(nsIMsgOfflineImapOperation *op)
}
}
}
}
}
// I'm tempted to make this a method on nsIMsgFolder, but that interface
// is already so huge, and there are only a few places in the code that do this.
@ -635,18 +637,18 @@ void nsImapOfflineSync::ProcessCopyOperation(nsIMsgOfflineImapOperation *current
while (currentOp);
nsCAutoString uids;
nsCOMPtr<nsIMsgFolder> destFolder;
GetExistingFolder(copyDestination, getter_AddRefs(destFolder));
// if the dest folder doesn't really exist, these operations are
// going to fail, so clear them out and move on.
if (!destFolder)
{
NS_ERROR("trying to playing back copy to non-existent folder");
ClearCurrentOps();
ProcessNextOperation();
return;
}
nsresult rv;
nsCOMPtr<nsIRDFResource> res;
nsCOMPtr<nsIRDFService> rdf(do_GetService(kRDFServiceCID, &rv));
if (NS_FAILED(rv)) return ; // ### return error code.
rv = rdf->GetResource(copyDestination, getter_AddRefs(res));
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIMsgFolder> destFolder(do_QueryInterface(res, &rv));
if (NS_SUCCEEDED(rv) && destFolder)
{
nsCOMPtr<nsIMsgImapMailFolder> imapFolder = do_QueryInterface(m_currentFolder);
if (imapFolder && DestFolderOnSameServer(destFolder))
{
@ -673,8 +675,6 @@ void nsImapOfflineSync::ProcessCopyOperation(nsIMsgOfflineImapOperation *current
}
}
}
}
}
void nsImapOfflineSync::ProcessEmptyTrash(nsIMsgOfflineImapOperation *currentOp)
{

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

@ -72,6 +72,7 @@ protected:
nsresult AdvanceToNextFolder();
void AdvanceToFirstIMAPFolder();
void DeleteAllOfflineOpsForCurrentDB();
void ClearCurrentOps();
void ProcessFlagOperation(nsIMsgOfflineImapOperation *currentOp);
void ProcessKeywordOperation(nsIMsgOfflineImapOperation *op);