From 3e285230a812b809f7c9c4e692e3516cce97ff68 Mon Sep 17 00:00:00 2001 From: "bienvenu%nventure.com" Date: Thu, 2 Sep 2004 22:46:21 +0000 Subject: [PATCH] fix 257682 problem with sending multiple mapi messages simultaneously with the same attachment name, sr=mscott --- mailnews/mapi/mapihook/src/msgMapiHook.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mailnews/mapi/mapihook/src/msgMapiHook.cpp b/mailnews/mapi/mapihook/src/msgMapiHook.cpp index bd31b3215ae5..95545cd15c6d 100644 --- a/mailnews/mapi/mapihook/src/msgMapiHook.cpp +++ b/mailnews/mapi/mapihook/src/msgMapiHook.cpp @@ -546,6 +546,7 @@ nsresult nsMapiHook::HandleAttachments (nsIMsgCompFields * aCompFields, PRInt32 PRBool bExist ; rv = pFile->Exists(&bExist) ; + PR_LOG(MAPI, PR_LOG_DEBUG, ("nsMapiHook::HandleAttachments: filename: %s path: %s exists = %s \n", (const char*)aFiles[i].lpszFileName, (const char*)aFiles[i].lpszPathName, bExist ? "true" : "false")); if (NS_FAILED(rv) || (!bExist) ) return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST ; //Temp Directory @@ -578,6 +579,20 @@ nsresult nsMapiHook::HandleAttachments (nsIMsgCompFields * aCompFields, PRInt32 else pFile->GetLeafName (leafName); + nsCOMPtr pTempFile; + rv = pTempDir->Clone(getter_AddRefs(pTempFile)); + if (NS_FAILED(rv) || (!pTempFile) ) + return rv; + + pTempFile->Append(leafName); + pTempFile->Exists(&bExist); + if (bExist) + { + rv = pTempFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0777); + NS_ENSURE_SUCCESS(rv, rv); + pTempFile->GetLeafName(leafName); + pTempFile->Remove(PR_FALSE); // remove so we can copy over it. + } // copy the file to its new location and file name pFile->CopyTo(pTempDir, leafName); // point pFile to the new location of the attachment @@ -596,6 +611,8 @@ nsresult nsMapiHook::HandleAttachments (nsIMsgCompFields * aCompFields, PRInt32 // add the attachment rv = aCompFields->AddAttachment (attachment); + if (NS_FAILED(rv)) + PR_LOG(MAPI, PR_LOG_DEBUG, ("nsMapiHook::HandleAttachments: AddAttachment rv = %lx\n", rv)); } } return rv ;