Index: src/libchcore/TFilesystemFeedbackWrapper.cpp =================================================================== diff -u -rc0d9a798f9fbbeda239b84721ed864f9727e1ddc -rfc42a6399299d4b90268695740a9e6e35ab25b05 --- src/libchcore/TFilesystemFeedbackWrapper.cpp (.../TFilesystemFeedbackWrapper.cpp) (revision c0d9a798f9fbbeda239b84721ed864f9727e1ddc) +++ src/libchcore/TFilesystemFeedbackWrapper.cpp (.../TFilesystemFeedbackWrapper.cpp) (revision fc42a6399299d4b90268695740a9e6e35ab25b05) @@ -66,17 +66,17 @@ TFeedbackResult frResult = m_spFeedbackHandler->FileError(pathDirectory.ToWString(), TString(), EFileError::eCreateError, dwLastError); switch (frResult.GetResult()) { - case EFeedbackResult::eResult_Cancel: + case eResult_Cancel: return TSubTaskBase::eSubResult_CancelRequest; - case EFeedbackResult::eResult_Retry: + case eResult_Retry: bRetry = true; break; - case EFeedbackResult::eResult_Pause: + case eResult_Pause: return TSubTaskBase::eSubResult_PauseRequest; - case EFeedbackResult::eResult_Skip: + case eResult_Skip: return TSubTaskBase::eSubResult_Continue; default: @@ -135,17 +135,17 @@ frResult = m_spFeedbackHandler->FileError(pathDestination.ToWString(), TString(), EFileError::eCheckForFreeSpace, dwLastError); switch (frResult.GetResult()) { - case EFeedbackResult::eResult_Cancel: + case eResult_Cancel: return TSubTaskBase::eSubResult_CancelRequest; - case EFeedbackResult::eResult_Retry: + case eResult_Retry: bRetry = true; break; - case EFeedbackResult::eResult_Pause: + case eResult_Pause: return TSubTaskBase::eSubResult_PauseRequest; - case EFeedbackResult::eResult_Skip: + case eResult_Skip: return TSubTaskBase::eSubResult_Continue; default: @@ -164,16 +164,16 @@ frResult = m_spFeedbackHandler->NotEnoughSpace(pathFirstSrc.ToWString(), pathDestination.ToWString(), ullNeededSize); switch (frResult.GetResult()) { - case EFeedbackResult::eResult_Cancel: + case eResult_Cancel: LOG_INFO(m_spLog) << _T("Cancel request while checking for free space on disk."); return TSubTaskBase::eSubResult_CancelRequest; - case EFeedbackResult::eResult_Retry: + case eResult_Retry: LOG_INFO(m_spLog) << _T("Retrying to read drive's free space..."); bRetry = true; break; - case EFeedbackResult::eResult_Ignore: + case eResult_Ignore: LOG_INFO(m_spLog) << _T("Ignored warning about not enough place on disk to copy data."); return TSubTaskBase::eSubResult_Continue; @@ -225,18 +225,18 @@ TFeedbackResult frResult = m_spFeedbackHandler->FileError(spFileInfo->GetFullFilePath().ToWString(), TString(), EFileError::eDeleteError, dwLastError); switch (frResult.GetResult()) { - case EFeedbackResult::eResult_Cancel: + case eResult_Cancel: LOG_INFO(m_spLog) << _T("Cancel request while deleting file."); return TSubTaskBase::eSubResult_CancelRequest; - case EFeedbackResult::eResult_Retry: + case eResult_Retry: bRetry = true; break; // no fcIndex bump, since we are trying again - case EFeedbackResult::eResult_Pause: + case eResult_Pause: return TSubTaskBase::eSubResult_PauseRequest; - case EFeedbackResult::eResult_Skip: + case eResult_Skip: return TSubTaskBase::eSubResult_Continue; // just do nothing default: @@ -286,18 +286,18 @@ TFeedbackResult frResult = m_spFeedbackHandler->FileError(spFileInfo->GetFullFilePath().ToWString(), TString(), EFileError::eDeleteError, dwLastError); switch (frResult.GetResult()) { - case EFeedbackResult::eResult_Cancel: + case eResult_Cancel: LOG_INFO(m_spLog) << _T("Cancel request while deleting file."); return TSubTaskBase::eSubResult_CancelRequest; - case EFeedbackResult::eResult_Retry: + case eResult_Retry: bRetry = true; break; - case EFeedbackResult::eResult_Pause: + case eResult_Pause: return TSubTaskBase::eSubResult_PauseRequest; - case EFeedbackResult::eResult_Skip: + case eResult_Skip: return TSubTaskBase::eSubResult_Continue; // just do nothing default: @@ -350,17 +350,17 @@ TFeedbackResult frResult = m_spFeedbackHandler->FileError(pathSrc.ToWString(), pathDestination.ToWString(), EFileError::eFastMoveError, dwLastError); switch (frResult.GetResult()) { - case EFeedbackResult::eResult_Cancel: + case eResult_Cancel: return TSubTaskBase::eSubResult_CancelRequest; - case EFeedbackResult::eResult_Retry: + case eResult_Retry: bRetry = true; break; - case EFeedbackResult::eResult_Pause: + case eResult_Pause: return TSubTaskBase::eSubResult_PauseRequest; - case EFeedbackResult::eResult_Skip: + case eResult_Skip: return TSubTaskBase::eSubResult_SkipFile; default: @@ -398,17 +398,17 @@ TFeedbackResult frResult = m_spFeedbackHandler->FileError(pathCurrent.ToWString(), TString(), EFileError::eRetrieveFileInfo, dwLastError); switch (frResult.GetResult()) { - case EFeedbackResult::eResult_Cancel: + case eResult_Cancel: return TSubTaskBase::eSubResult_CancelRequest; - case EFeedbackResult::eResult_Retry: + case eResult_Retry: bRetry = true; break; - case EFeedbackResult::eResult_Pause: + case eResult_Pause: return TSubTaskBase::eSubResult_PauseRequest; - case EFeedbackResult::eResult_Skip: + case eResult_Skip: return TSubTaskBase::eSubResult_SkipFile; default: Index: src/libchcore/TFilesystemFileFeedbackWrapper.cpp =================================================================== diff -u -rc0d9a798f9fbbeda239b84721ed864f9727e1ddc -rfc42a6399299d4b90268695740a9e6e35ab25b05 --- src/libchcore/TFilesystemFileFeedbackWrapper.cpp (.../TFilesystemFileFeedbackWrapper.cpp) (revision c0d9a798f9fbbeda239b84721ed864f9727e1ddc) +++ src/libchcore/TFilesystemFileFeedbackWrapper.cpp (.../TFilesystemFileFeedbackWrapper.cpp) (revision fc42a6399299d4b90268695740a9e6e35ab25b05) @@ -55,27 +55,27 @@ TFeedbackResult frResult = m_spFeedbackHandler->FileAlreadyExists(*spSrcFileInfo, tDstFileInfo); switch(frResult.GetResult()) { - case EFeedbackResult::eResult_Overwrite: + case eResult_Overwrite: bShouldAppend = false; return TSubTaskBase::eSubResult_Continue; - case EFeedbackResult::eResult_CopyRest: + case eResult_CopyRest: bShouldAppend = true; return TSubTaskBase::eSubResult_Continue; - case EFeedbackResult::eResult_Skip: + case eResult_Skip: return TSubTaskBase::eSubResult_SkipFile; - case EFeedbackResult::eResult_Cancel: + case eResult_Cancel: { // log - TString strFormat = _T("Cancel request while checking result of dialog before opening source file %path (CustomCopyFileFB)"); + TString strFormat = _T("Cancel request when handling already existing file %path"); strFormat.Replace(_T("%path"), m_spFile->GetFilePath().ToString()); LOG_INFO(m_spLog) << strFormat.c_str(); return TSubTaskBase::eSubResult_CancelRequest; } - case EFeedbackResult::eResult_Pause: + case eResult_Pause: return TSubTaskBase::eSubResult_PauseRequest; default: @@ -109,17 +109,17 @@ TFeedbackResult frResult = m_spFeedbackHandler->FileError(m_spFile->GetFilePath().ToWString(), TString(), EFileError::eResizeError, dwLastError); switch (frResult.GetResult()) { - case EFeedbackResult::eResult_Cancel: + case eResult_Cancel: return TSubTaskBase::eSubResult_CancelRequest; - case EFeedbackResult::eResult_Retry: + case eResult_Retry: bRetry = true; break; - case EFeedbackResult::eResult_Pause: + case eResult_Pause: return TSubTaskBase::eSubResult_PauseRequest; - case EFeedbackResult::eResult_Skip: + case eResult_Skip: return TSubTaskBase::eSubResult_SkipFile; default: @@ -154,7 +154,7 @@ dwLastError = e.GetNativeError(); } - TString strFormat = _T("Error %errno while requesting read of %count bytes from source file %path (CustomCopyFileFB)"); + TString strFormat = _T("Error %errno while requesting read of %count bytes from source file %path"); strFormat.Replace(_T("%errno"), boost::lexical_cast(dwLastError).c_str()); strFormat.Replace(_T("%count"), boost::lexical_cast(rBuffer.GetRequestedDataSize()).c_str()); strFormat.Replace(_T("%path"), m_spFile->GetFilePath().ToString()); @@ -163,17 +163,17 @@ TFeedbackResult frResult = m_spFeedbackHandler->FileError(m_spFile->GetFilePath().ToWString(), TString(), EFileError::eReadError, dwLastError); switch (frResult.GetResult()) { - case EFeedbackResult::eResult_Cancel: + case eResult_Cancel: return TSubTaskBase::eSubResult_CancelRequest; - case EFeedbackResult::eResult_Retry: + case eResult_Retry: bRetry = true; break; - case EFeedbackResult::eResult_Pause: + case eResult_Pause: return TSubTaskBase::eSubResult_PauseRequest; - case EFeedbackResult::eResult_Skip: + case eResult_Skip: return TSubTaskBase::eSubResult_SkipFile; default: @@ -208,7 +208,7 @@ dwLastError = e.GetNativeError(); } - TString strFormat = _T("Error %errno while trying to write %count bytes to destination file %path (CustomCopyFileFB)"); + TString strFormat = _T("Error %errno while trying to write %count bytes to destination file %path"); strFormat.Replace(_T("%errno"), boost::lexical_cast(dwLastError).c_str()); strFormat.Replace(_T("%count"), boost::lexical_cast(rBuffer.GetBytesTransferred()).c_str()); strFormat.Replace(_T("%path"), m_spFile->GetFilePath().ToString()); @@ -217,17 +217,17 @@ TFeedbackResult frResult = m_spFeedbackHandler->FileError(m_spFile->GetFilePath().ToWString(), TString(), EFileError::eWriteError, dwLastError); switch (frResult.GetResult()) { - case EFeedbackResult::eResult_Cancel: + case eResult_Cancel: return TSubTaskBase::eSubResult_CancelRequest; - case EFeedbackResult::eResult_Retry: + case eResult_Retry: bRetry = true; break; - case EFeedbackResult::eResult_Pause: + case eResult_Pause: return TSubTaskBase::eSubResult_PauseRequest; - case EFeedbackResult::eResult_Skip: + case eResult_Skip: return TSubTaskBase::eSubResult_SkipFile; default: @@ -262,25 +262,25 @@ dwLastError = e.GetNativeError(); } - TString strFormat = _T("Error %errno while trying to finalize file %path (CustomCopyFileFB)"); + TString strFormat = _T("Error %errno while trying to finalize file %path"); strFormat.Replace(_T("%errno"), boost::lexical_cast(dwLastError).c_str()); strFormat.Replace(_T("%path"), m_spFile->GetFilePath().ToString()); LOG_ERROR(m_spLog) << strFormat.c_str(); TFeedbackResult frResult = m_spFeedbackHandler->FileError(m_spFile->GetFilePath().ToWString(), TString(), EFileError::eFinalizeError, dwLastError); switch (frResult.GetResult()) { - case EFeedbackResult::eResult_Cancel: + case eResult_Cancel: return TSubTaskBase::eSubResult_CancelRequest; - case EFeedbackResult::eResult_Retry: + case eResult_Retry: bRetry = true; break; - case EFeedbackResult::eResult_Pause: + case eResult_Pause: return TSubTaskBase::eSubResult_PauseRequest; - case EFeedbackResult::eResult_Skip: + case eResult_Skip: return TSubTaskBase::eSubResult_SkipFile; default: @@ -301,7 +301,7 @@ DWORD dwLastError = rBuffer.GetErrorCode(); // log - TString strFormat = _T("Error %errno while requesting read of %count bytes from source file %path (CustomCopyFileFB)"); + TString strFormat = _T("Error %errno while requesting read of %count bytes from source file %path"); strFormat.Replace(_T("%errno"), boost::lexical_cast(dwLastError).c_str()); strFormat.Replace(_T("%count"), boost::lexical_cast(rBuffer.GetRequestedDataSize()).c_str()); strFormat.Replace(_T("%path"), m_spFile->GetFilePath().ToString()); @@ -310,16 +310,16 @@ TFeedbackResult frResult = m_spFeedbackHandler->FileError(m_spFile->GetFilePath().ToWString(), TString(), EFileError::eReadError, dwLastError); switch(frResult.GetResult()) { - case EFeedbackResult::eResult_Cancel: + case eResult_Cancel: return TSubTaskBase::eSubResult_CancelRequest; - case EFeedbackResult::eResult_Retry: + case eResult_Retry: return TSubTaskBase::eSubResult_Retry; - case EFeedbackResult::eResult_Pause: + case eResult_Pause: return TSubTaskBase::eSubResult_PauseRequest; - case EFeedbackResult::eResult_Skip: + case eResult_Skip: return TSubTaskBase::eSubResult_SkipFile; default: @@ -333,7 +333,7 @@ DWORD dwLastError = rBuffer.GetErrorCode(); // log - TString strFormat = _T("Error %errno while trying to write %count bytes to destination file %path (CustomCopyFileFB)"); + TString strFormat = _T("Error %errno while trying to write %count bytes to destination file %path"); strFormat.Replace(_T("%errno"), boost::lexical_cast(rBuffer.GetErrorCode()).c_str()); strFormat.Replace(_T("%count"), boost::lexical_cast(rBuffer.GetBytesTransferred()).c_str()); strFormat.Replace(_T("%path"), m_spFile->GetFilePath().ToString()); @@ -342,16 +342,16 @@ TFeedbackResult frResult = m_spFeedbackHandler->FileError(m_spFile->GetFilePath().ToWString(), TString(), EFileError::eWriteError, dwLastError); switch(frResult.GetResult()) { - case EFeedbackResult::eResult_Cancel: + case eResult_Cancel: return TSubTaskBase::eSubResult_CancelRequest; - case EFeedbackResult::eResult_Retry: + case eResult_Retry: return TSubTaskBase::eSubResult_Retry; - case EFeedbackResult::eResult_Pause: + case eResult_Pause: return TSubTaskBase::eSubResult_PauseRequest; - case EFeedbackResult::eResult_Skip: + case eResult_Skip: return TSubTaskBase::eSubResult_SkipFile; default: @@ -360,9 +360,57 @@ } } - bool TFilesystemFileFeedbackWrapper::IsFreshlyCreated() const + TSubTaskBase::ESubOperationResult TFilesystemFileFeedbackWrapper::IsFreshlyCreated(bool& bIsFreshlyCreated) const { - return m_spFile->IsFreshlyCreated(); + bool bRetry = false; + do + { + bRetry = false; + + DWORD dwLastError = ERROR_SUCCESS; + + try + { + bIsFreshlyCreated = m_spFile->IsFreshlyCreated(); + return TSubTaskBase::eSubResult_Continue; + } + catch(const TFileException& e) + { + dwLastError = e.GetNativeError(); + } + + TString strFormat = _T("Error %errno while trying to retrieve freshly-created flag for file %path"); + strFormat.Replace(_T("%errno"), boost::lexical_cast(dwLastError).c_str()); + strFormat.Replace(_T("%path"), m_spFile->GetFilePath().ToString()); + LOG_ERROR(m_spLog) << strFormat.c_str(); + + TFeedbackResult frResult = m_spFeedbackHandler->FileError(m_spFile->GetFilePath().ToWString(), TString(), EFileError::eCreateError, dwLastError); + switch(frResult.GetResult()) + { + case eResult_Cancel: + return TSubTaskBase::eSubResult_CancelRequest; + + case eResult_Retry: + bRetry = true; + break; + + case eResult_Pause: + return TSubTaskBase::eSubResult_PauseRequest; + + case eResult_Skip: + return TSubTaskBase::eSubResult_SkipFile; + + default: + BOOST_ASSERT(FALSE); // unknown result + throw TCoreException(eErr_UnhandledCase, L"Feedback result unknown", LOCATION); + } + + if(WasKillRequested(frResult)) + return TSubTaskBase::eSubResult_KillRequest; + } + while(bRetry); + + return TSubTaskBase::eSubResult_Continue; } TSmartPath TFilesystemFileFeedbackWrapper::GetFilePath() const @@ -389,25 +437,25 @@ dwLastError = e.GetNativeError(); } - TString strFormat = _T("Error %errno while trying to finalize file %path (CustomCopyFileFB)"); + TString strFormat = _T("Error %errno while trying to retrieve file size of file %path"); strFormat.Replace(_T("%errno"), boost::lexical_cast(dwLastError).c_str()); strFormat.Replace(_T("%path"), m_spFile->GetFilePath().ToString()); LOG_ERROR(m_spLog) << strFormat.c_str(); - TFeedbackResult frResult = m_spFeedbackHandler->FileError(m_spFile->GetFilePath().ToWString(), TString(), EFileError::eFinalizeError, dwLastError); + TFeedbackResult frResult = m_spFeedbackHandler->FileError(m_spFile->GetFilePath().ToWString(), TString(), EFileError::eRetrieveFileInfo, dwLastError); switch(frResult.GetResult()) { - case EFeedbackResult::eResult_Cancel: + case eResult_Cancel: return TSubTaskBase::eSubResult_CancelRequest; - case EFeedbackResult::eResult_Retry: + case eResult_Retry: bRetry = true; break; - case EFeedbackResult::eResult_Pause: + case eResult_Pause: return TSubTaskBase::eSubResult_PauseRequest; - case EFeedbackResult::eResult_Skip: + case eResult_Skip: return TSubTaskBase::eSubResult_SkipFile; default: Index: src/libchcore/TFilesystemFileFeedbackWrapper.h =================================================================== diff -u -rc0d9a798f9fbbeda239b84721ed864f9727e1ddc -rfc42a6399299d4b90268695740a9e6e35ab25b05 --- src/libchcore/TFilesystemFileFeedbackWrapper.h (.../TFilesystemFileFeedbackWrapper.h) (revision c0d9a798f9fbbeda239b84721ed864f9727e1ddc) +++ src/libchcore/TFilesystemFileFeedbackWrapper.h (.../TFilesystemFileFeedbackWrapper.h) (revision fc42a6399299d4b90268695740a9e6e35ab25b05) @@ -49,7 +49,8 @@ TSubTaskBase::ESubOperationResult HandleReadError(TOverlappedDataBuffer& rBuffer); TSubTaskBase::ESubOperationResult HandleWriteError(TOverlappedDataBuffer& rBuffer); - bool IsFreshlyCreated() const; + TSubTaskBase::ESubOperationResult IsFreshlyCreated(bool& bIsFreshlyCreated) const; + TSmartPath GetFilePath() const; TSubTaskBase::ESubOperationResult GetFileSize(file_size_t& fsSize) const; file_size_t GetSeekPositionForResume(file_size_t fsLastAvailablePosition); Index: src/libchcore/TSubTaskCopyMove.cpp =================================================================== diff -u -rc0d9a798f9fbbeda239b84721ed864f9727e1ddc -rfc42a6399299d4b90268695740a9e6e35ab25b05 --- src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision c0d9a798f9fbbeda239b84721ed864f9727e1ddc) +++ src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision fc42a6399299d4b90268695740a9e6e35ab25b05) @@ -421,9 +421,12 @@ unsigned long long ullProcessedSize = m_spSubTaskStats->GetCurrentItemProcessedSize(); unsigned long long ullSeekTo = ullProcessedSize; - bool bDstFileFreshlyCreated = rDstFile.IsFreshlyCreated(); - file_size_t fsDstFileSize = 0; + bool bDstFileFreshlyCreated = false; + eResult = rDstFile.IsFreshlyCreated(bDstFileFreshlyCreated); + if(eResult != eSubResult_Continue) + return eResult; + file_size_t fsDstFileSize = 0; eResult = rDstFile.GetFileSize(fsDstFileSize); if(eResult != eSubResult_Continue) return eResult;