Open UglyPhone opened 8 months ago
Hi,
I will need a bit more details.
Thanks
I will recreate the test, provide instructions how to to recreate.
I think I recreated the reported case. It seems that you are running "File->Select root folder for merging" option and there is no duplicate messages found during merge. MBox Viewer attempts to move final file to different location but that fails. It seems that the file to be moved may not be closed by MBox Viewer when it attempts to move that file and the move the file fails. I need to examine closer why this is happening and resolve either by copy final file instead of move the file or some other solution. I will provide an update to you.
When you copy and add the same file for merging, you don't see the same problem as you reported. Move file is not called in this case.
I think I recreated the reported case. It seems that you are running "File->Select root folder for merging" option and there is no duplicate messages found during merge. MBox Viewer attempts to move final file to different location but that fails. It seems that the file to be moved may not be closed by MBox Viewer when it attempts to move that file and the move the file fails. I need to examine closer why this is happening and resolve either by copy final file instead of move the file or some other solution. I will provide an update to you.
When you copy and add the same file for merging, you don't see the same problem as you reported. Move file is not called in this case.
I don't know if I expressed myself clearly. When I was merging the root directory, I called the OnFileMergerrootfoldersub function with a treetype of 2. When I reached NTreeView: ArchiveMailsRemoveDuplicates (CFile&fp, CString&filePath), an exception occurred. The mbox file was already generated, but the s'emails GetSize() is equal to s'mailsArray GetSize() caused the move to fail, but I copied one of the EML files from the folder to the same directory, s'emails GetSize() is not equal to s'mailsArray GetSize(), mbox files can be moved to a directory.
Thanks for reporting the issue. I made a quick fix and submitted fix to github. MoveFileEx differs from CopyFiles. It fails when the destination file is open. Check the files in the github. I made the following changes (see CFile::hFileNull):
int NTreeView::ArchiveMailsRemoveDuplicates(CFile& fp, CString& filePath)
{
MailArray& s_mails_array = MboxMail::s_mails_all;
BOOL putDuplicatesOnFindArray = FALSE;
int dupCnt = MboxMail::RemoveDuplicateMails(s_mails_array, putDuplicatesOnFindArray);
if (dupCnt == 0)
{
#if 1
// TODO: MoveFileEx fails because fp is open
// Need to close fp or use WCopyFile
// MoveFileEx avoids copy file if source and destinations are on the the volume
// More efficient if merge file is very large
if (m_rootMboxCfile.m_hFile != CFile::hFileNull) // use of m_hFile not recommended in some cases according to windows doc
fp.Close();
int NTreeView::MergeTreeFolders(MBoxFolderTree& tree, CString& errorText)
{
....................
FileUtils::CPathStripPath(filePath, fname);
sText.Format(L"Removing duplicate mails in the final file %s ...", fname);
if (pFrame)
pFrame->SetStatusBarPaneText(paneId, sText, TRUE);
if (pFrame->m_labelAssignmentStyle != 0)
MergeMailsRemoveDuplicates();
else
ArchiveMailsRemoveDuplicates(m_rootMboxCfile, filePath);
MboxMail::Destroy(&MboxMail::s_mails);
if (m_rootMboxCfile.m_hFile != CFile::hFileNull )
m_rootMboxCfile.Close();
FileUtils::DelFile(m_rootMboxFilePath);
Thanks for reporting the issue. I made a quick fix and submitted fix to github. MoveFileEx differs from CopyFiles. It fails when the destination file is open. Check the files in the github. I made the following changes (see CFile::hFileNull):
int NTreeView::ArchiveMailsRemoveDuplicates(CFile& fp, CString& filePath) { MailArray& s_mails_array = MboxMail::s_mails_all; BOOL putDuplicatesOnFindArray = FALSE; int dupCnt = MboxMail::RemoveDuplicateMails(s_mails_array, putDuplicatesOnFindArray); if (dupCnt == 0) { #if 1 // TODO: MoveFileEx fails because fp is open // Need to close fp or use WCopyFile // MoveFileEx avoids copy file if source and destinations are on the the volume // More efficient if merge file is very large if (m_rootMboxCfile.m_hFile != CFile::hFileNull) // use of m_hFile not recommended in some cases according to windows doc fp.Close(); int NTreeView::MergeTreeFolders(MBoxFolderTree& tree, CString& errorText) { .................... FileUtils::CPathStripPath(filePath, fname); sText.Format(L"Removing duplicate mails in the final file %s ...", fname); if (pFrame) pFrame->SetStatusBarPaneText(paneId, sText, TRUE); if (pFrame->m_labelAssignmentStyle != 0) MergeMailsRemoveDuplicates(); else ArchiveMailsRemoveDuplicates(m_rootMboxCfile, filePath); MboxMail::Destroy(&MboxMail::s_mails); if (m_rootMboxCfile.m_hFile != CFile::hFileNull ) m_rootMboxCfile.Close(); FileUtils::DelFile(m_rootMboxFilePath);
Thank you very much.I copied the code locally and moved the mbox to the cache directory, but there was another issue where the archived mbox file was not added to the software interface.
You need to provide more details about new issue you have.
You need to provide more details about new issue you have.
Sorry, this is my fault. it`s ok when I recompile it.
I have encountered a problem, I don't know if it's just me who has this problem
When I export multiple EML files to mbox, it always prompts Failed to move file xxx code 5. When I check the code, int dupCnt=MboxMail:: RemoveDuplicateMails_Generic (s'mailsArray); Always 0, but once I copy one of the EML files, there won't be this error. Can you help me answer this question? Thank you