Index: src/libchcore/TSubTaskFastMove.cpp =================================================================== diff -u -rcde3645c5041aedd6703b81b6fed42134c615917 -r25722a1d39e5d4bb49c5a60cbee3dda6c02cb193 --- src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision cde3645c5041aedd6703b81b6fed42134c615917) +++ src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision 25722a1d39e5d4bb49c5a60cbee3dda6c02cb193) @@ -40,6 +40,7 @@ #include "TFeedbackHandlerWrapper.h" #include "TBufferSizes.h" #include "TFileException.h" +#include "TFilesystemFeedbackWrapper.h" namespace chcore { @@ -72,6 +73,8 @@ const TFileFiltersArray& rafFilters = GetContext().GetFilters(); IFilesystemPtr spFilesystem = GetContext().GetLocalFilesystem(); + TFilesystemFeedbackWrapper tFilesystemFBWrapper(spFeedbackHandler, spFilesystem, rLog); + rLog.logi(_T("Performing initial fast-move operation...")); // new stats @@ -115,7 +118,7 @@ TFileInfoPtr spFileInfo(boost::make_shared()); bool bSkip = false; - ESubOperationResult eResult = GetFileInfoFB(spFeedbackHandler, pathCurrent, spFileInfo, spBasePath, bSkip); + ESubOperationResult eResult = tFilesystemFBWrapper.GetFileInfoFB(pathCurrent, spFileInfo, spBasePath, bSkip); if (eResult != TSubTaskBase::eSubResult_Continue) return eResult; else if (bSkip) @@ -129,7 +132,7 @@ } // try to fast move - eResult = FastMoveFB(spFeedbackHandler, spFileInfo, pathDestination, spBasePath, bSkip); + eResult = tFilesystemFBWrapper.FastMoveFB(spFileInfo, CalculateDestinationPath(spFileInfo, pathDestination, 0), spBasePath, bSkip); if (eResult != TSubTaskBase::eSubResult_Continue) return eResult; //else if (bSkip) @@ -154,124 +157,6 @@ return eSubResult_Continue; } - TSubTaskBase::ESubOperationResult TSubTaskFastMove::FastMoveFB(const IFeedbackHandlerPtr& spFeedbackHandler, const TFileInfoPtr& spFileInfo, const TSmartPath& pathDestination, - const TBasePathDataPtr& spBasePath, bool& bSkip) - { - IFilesystemPtr spFilesystem = GetContext().GetLocalFilesystem(); - icpf::log_file& rLog = GetContext().GetLog(); - - bool bRetry = false; - do - { - bRetry = false; - - TSmartPath pathDestinationPath = CalculateDestinationPath(spFileInfo, pathDestination, 0); - TSmartPath pathSrc = spBasePath->GetSrcPath(); - - DWORD dwLastError = ERROR_SUCCESS; - try - { - spFilesystem->FastMove(pathSrc, pathDestinationPath); - spBasePath->SetSkipFurtherProcessing(true); // mark that this path should not be processed any further - return eSubResult_Continue; - } - catch (const TFileException& e) - { - dwLastError = e.GetNativeError(); - } - - // check if this is one of the errors, that will just cause fast move to skip - if (dwLastError == ERROR_ACCESS_DENIED || dwLastError == ERROR_ALREADY_EXISTS || dwLastError == ERROR_NOT_SAME_DEVICE) - { - bSkip = true; - break; - } - else - { - //log - TString strFormat = _T("Error %errno while calling fast move %srcpath -> %dstpath (TSubTaskFastMove)"); - strFormat.Replace(_T("%errno"), boost::lexical_cast(dwLastError).c_str()); - strFormat.Replace(_T("%srcpath"), spFileInfo->GetFullFilePath().ToString()); - strFormat.Replace(_T("%dstpath"), pathDestination.ToString()); - rLog.loge(strFormat.c_str()); - - EFeedbackResult frResult = spFeedbackHandler->FileError(pathSrc.ToWString(), pathDestinationPath.ToWString(), EFileError::eFastMoveError, dwLastError); - switch (frResult) - { - case EFeedbackResult::eResult_Cancel: - return TSubTaskBase::eSubResult_CancelRequest; - - case EFeedbackResult::eResult_Retry: - bRetry = true; - break; - - case EFeedbackResult::eResult_Pause: - return TSubTaskBase::eSubResult_PauseRequest; - - case EFeedbackResult::eResult_Skip: - bSkip = true; - break; // just do nothing - - default: - BOOST_ASSERT(FALSE); // unknown result - THROW_CORE_EXCEPTION(eErr_UnhandledCase); - } - } - } - while (bRetry); - - return eSubResult_Continue; - } - - TSubTaskBase::ESubOperationResult TSubTaskFastMove::GetFileInfoFB(const IFeedbackHandlerPtr& spFeedbackHandler, const TSmartPath& pathCurrent, - TFileInfoPtr& spFileInfo, const TBasePathDataPtr& spBasePath, bool& bSkip) - { - const IFilesystemPtr& spFilesystem = GetContext().GetLocalFilesystem(); - - bool bRetry = false; - do - { - bRetry = false; - - // read attributes of src file/folder - DWORD dwLastError = ERROR_SUCCESS; - try - { - spFilesystem->GetFileInfo(pathCurrent, spFileInfo, spBasePath); - return eSubResult_Continue; - } - catch (const TFileException& e) - { - dwLastError = e.GetNativeError(); - } - - EFeedbackResult frResult = spFeedbackHandler->FileError(pathCurrent.ToWString(), TString(), EFileError::eFastMoveError, dwLastError); - switch (frResult) - { - case EFeedbackResult::eResult_Cancel: - return eSubResult_CancelRequest; - - case EFeedbackResult::eResult_Retry: - bRetry = true; - break; - - case EFeedbackResult::eResult_Pause: - return eSubResult_PauseRequest; - - case EFeedbackResult::eResult_Skip: - bSkip = true; - break; // just do nothing - - default: - BOOST_ASSERT(FALSE); // unknown result - THROW_CORE_EXCEPTION(eErr_UnhandledCase); - } - } - while (bRetry); - - return eSubResult_Continue; - } - void TSubTaskFastMove::GetStatsSnapshot(TSubTaskStatsSnapshotPtr& spStats) const { m_tSubTaskStats.GetSnapshot(spStats);