Index: src/libchcore/TSQLiteTaskSchema.cpp =================================================================== diff -u -N -rd76d3ce6c8c55fa23009dbb03b8bc06f482c5b72 -r79399818d01f20d3a83766543e98ef5f0ee3de38 --- src/libchcore/TSQLiteTaskSchema.cpp (.../TSQLiteTaskSchema.cpp) (revision d76d3ce6c8c55fa23009dbb03b8bc06f482c5b72) +++ src/libchcore/TSQLiteTaskSchema.cpp (.../TSQLiteTaskSchema.cpp) (revision 79399818d01f20d3a83766543e98ef5f0ee3de38) @@ -94,6 +94,20 @@ tVersion.SetVersion(1); } + if (tVersion.GetVersion() == 1) + { + sqlite::TSQLiteStatement tStatement(spDatabase); + + tStatement.Prepare(_T("ALTER TABLE subtask_fastmove ADD COLUMN ci_silent_resume boolean NOT NULL DEFAULT false")); + tStatement.Step(); + tStatement.Prepare(_T("ALTER TABLE subtask_delete ADD COLUMN ci_silent_resume boolean NOT NULL DEFAULT false")); + tStatement.Step(); + tStatement.Prepare(_T("ALTER TABLE subtask_copymove ADD COLUMN ci_silent_resume boolean NOT NULL DEFAULT false")); + tStatement.Step(); + + tVersion.SetVersion(2); + } + tTransaction.Commit(); } Index: src/libchcore/TSubTaskCopyMove.cpp =================================================================== diff -u -N -r04a9f2496d5931c7e06ff815fb8d0e3eabaf2cf2 -r79399818d01f20d3a83766543e98ef5f0ee3de38 --- src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 04a9f2496d5931c7e06ff815fb8d0e3eabaf2cf2) +++ src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 79399818d01f20d3a83766543e98ef5f0ee3de38) @@ -102,6 +102,7 @@ file_count_t fcSize = rFilesCache.GetSize(); file_count_t fcIndex = m_tSubTaskStats.GetCurrentIndex(); unsigned long long ullCurrentItemProcessedSize = m_tSubTaskStats.GetCurrentItemProcessedSize(); + bool bCurrentFileSilentResume = m_tSubTaskStats.CanCurrentItemSilentResume(); bool bIgnoreFolders = GetTaskPropValue(rConfig); bool bForceDirectories = GetTaskPropValue(rConfig); @@ -148,6 +149,8 @@ m_tSubTaskStats.SetCurrentItemProcessedSize(ullCurrentItemProcessedSize); // preserve the processed size for the first item ullCurrentItemProcessedSize = 0; m_tSubTaskStats.SetCurrentItemTotalSize(spFileInfo->GetLength64()); + m_tSubTaskStats.SetCurrentItemSilentResume(bCurrentFileSilentResume); + bCurrentFileSilentResume = false; // set dest path with filename ccp.pathDstFile = CalculateDestinationPath(spFileInfo, pathDestination, ((int)bForceDirectories) << 1 | (int)bIgnoreFolders); @@ -467,10 +470,11 @@ SetFileAttributes(pData->pathDstFile.ToString(), FILE_ATTRIBUTE_NORMAL); // open destination file, handle the failures and possibly existence of the destination file - unsigned long long ullSeekTo = m_tSubTaskStats.GetCurrentItemProcessedSize(); + unsigned long long ullProcessedSize = m_tSubTaskStats.GetCurrentItemProcessedSize(); + unsigned long long ullSeekTo = 0; bool bDstFileFreshlyCreated = false; - if (ullSeekTo == 0) + if (!m_tSubTaskStats.CanCurrentItemSilentResume()) { // open destination file for case, when we start operation on this file (i.e. it is not resume of the // old operation) @@ -479,7 +483,7 @@ return eResult; else if(!fileDst.IsOpen()) { - unsigned long long ullDiff = pData->spSrcFile->GetLength64() - m_tSubTaskStats.GetCurrentItemProcessedSize(); + unsigned long long ullDiff = pData->spSrcFile->GetLength64() - ullProcessedSize; m_tSubTaskStats.IncreaseProcessedSize(ullDiff); m_tSubTaskStats.IncreaseCurrentItemProcessedSize(ullDiff); @@ -497,7 +501,7 @@ return eResult; else if(!fileDst.IsOpen()) { - unsigned long long ullDiff = pData->spSrcFile->GetLength64() - m_tSubTaskStats.GetCurrentItemProcessedSize(); + unsigned long long ullDiff = pData->spSrcFile->GetLength64() - ullProcessedSize; m_tSubTaskStats.IncreaseProcessedSize(ullDiff); m_tSubTaskStats.IncreaseCurrentItemProcessedSize(ullDiff); @@ -511,7 +515,7 @@ if(pData->bOnlyCreate) { // we don't copy contents, but need to increase processed size - unsigned long long ullDiff = pData->spSrcFile->GetLength64() - m_tSubTaskStats.GetCurrentItemProcessedSize(); + unsigned long long ullDiff = pData->spSrcFile->GetLength64() - ullProcessedSize; m_tSubTaskStats.IncreaseProcessedSize(ullDiff); m_tSubTaskStats.IncreaseCurrentItemProcessedSize(ullDiff); @@ -530,7 +534,7 @@ return eResult; else if(bSkip) { - unsigned long long ullDiff = pData->spSrcFile->GetLength64() - m_tSubTaskStats.GetCurrentItemProcessedSize(); + unsigned long long ullDiff = pData->spSrcFile->GetLength64() - ullProcessedSize; m_tSubTaskStats.IncreaseProcessedSize(ullDiff); m_tSubTaskStats.IncreaseCurrentItemProcessedSize(ullDiff); @@ -545,7 +549,7 @@ else if(bSkip) { // with either first or second seek we got 'skip' answer... - unsigned long long ullDiff = pData->spSrcFile->GetLength64() - m_tSubTaskStats.GetCurrentItemProcessedSize(); + unsigned long long ullDiff = pData->spSrcFile->GetLength64() - ullProcessedSize; m_tSubTaskStats.IncreaseProcessedSize(ullDiff); m_tSubTaskStats.IncreaseCurrentItemProcessedSize(ullDiff); @@ -555,16 +559,15 @@ } // adjust the stats for the difference between what was already processed and what will now be considered processed - unsigned long long ullCurrentProcessedSize = m_tSubTaskStats.GetCurrentItemProcessedSize(); - if (ullMove > ullCurrentProcessedSize) + if (ullMove > ullProcessedSize) { - unsigned long long ullDiff = ullMove - ullCurrentProcessedSize; + unsigned long long ullDiff = ullMove - ullProcessedSize; m_tSubTaskStats.IncreaseCurrentItemProcessedSize(ullDiff); m_tSubTaskStats.IncreaseProcessedSize(ullDiff); } - else if (ullMove < ullCurrentProcessedSize) + else if (ullMove < ullProcessedSize) { - unsigned long long ullDiff = ullCurrentProcessedSize - ullMove; + unsigned long long ullDiff = ullProcessedSize - ullMove; m_tSubTaskStats.DecreaseCurrentItemProcessedSize(ullDiff); m_tSubTaskStats.DecreaseProcessedSize(ullDiff); } @@ -584,6 +587,10 @@ } } + // at this point user already decided that he want to write data into destination file; + // so if we're to resume copying after this point, we don't have to ask user for overwriting existing file + m_tSubTaskStats.SetCurrentItemSilentResume(true); + return eResult; } Index: src/libchcore/TSubTaskStatsInfo.cpp =================================================================== diff -u -N -rd5005ff4b983f42d7f0da94e5a562dabe1399f78 -r79399818d01f20d3a83766543e98ef5f0ee3de38 --- src/libchcore/TSubTaskStatsInfo.cpp (.../TSubTaskStatsInfo.cpp) (revision d5005ff4b983f42d7f0da94e5a562dabe1399f78) +++ src/libchcore/TSubTaskStatsInfo.cpp (.../TSubTaskStatsInfo.cpp) (revision 79399818d01f20d3a83766543e98ef5f0ee3de38) @@ -64,7 +64,8 @@ m_eSubOperationType(m_setModifications, eSubOperation_None), m_tTimer(m_setModifications), m_bIsInitialized(m_setModifications, false), - m_fcCurrentIndex(m_setModifications, 0) + m_fcCurrentIndex(m_setModifications, 0), + m_bCurrentItemSilentResume(m_setModifications, false) { m_setModifications[eMod_Added] = true; } @@ -86,6 +87,7 @@ m_eSubOperationType = eSubOperation_None; m_bIsInitialized = false; m_fcCurrentIndex = 0; + m_bCurrentItemSilentResume = false; } void TSubTaskStatsInfo::GetSnapshot(TSubTaskStatsSnapshotPtr& spStatsSnapshot) const @@ -310,6 +312,8 @@ rRowData.SetValue(_T("ci_processed_size"), m_ullCurrentItemProcessedSize); if(m_ullCurrentItemTotalSize.IsModified()) rRowData.SetValue(_T("ci_total_size"), m_ullCurrentItemTotalSize); + if (m_bCurrentItemSilentResume.IsModified()) + rRowData.SetValue(_T("ci_silent_resume"), m_bCurrentItemSilentResume); if(m_fcCurrentIndex.IsModified()) rRowData.SetValue(_T("current_index"), m_fcCurrentIndex); @@ -340,6 +344,7 @@ rColumnDefs.AddColumn(_T("count_speed"), IColumnsDefinition::eType_string); rColumnDefs.AddColumn(_T("ci_processed_size"), IColumnsDefinition::eType_ulonglong); rColumnDefs.AddColumn(_T("ci_total_size"), IColumnsDefinition::eType_ulonglong); + rColumnDefs.AddColumn(_T("ci_silent_resume"), IColumnsDefinition::eType_bool); rColumnDefs.AddColumn(_T("current_index"), ColumnType::value); rColumnDefs.AddColumn(_T("timer"), IColumnsDefinition::eType_ulonglong); rColumnDefs.AddColumn(_T("buffer_index"), IColumnsDefinition::eType_int); @@ -370,6 +375,7 @@ spRowReader->GetValue(_T("ci_processed_size"), m_ullCurrentItemProcessedSize.Modify()); spRowReader->GetValue(_T("ci_total_size"), m_ullCurrentItemTotalSize.Modify()); + spRowReader->GetValue(_T("ci_silent_resume"), m_bCurrentItemSilentResume.Modify()); spRowReader->GetValue(_T("current_index"), m_fcCurrentIndex.Modify()); unsigned long long ullTimer = 0; @@ -443,6 +449,18 @@ return m_ullCurrentItemTotalSize; } +bool TSubTaskStatsInfo::CanCurrentItemSilentResume() const +{ + boost::shared_lock lock(m_lock); + return m_bCurrentItemSilentResume; +} + +void TSubTaskStatsInfo::SetCurrentItemSilentResume(bool bEnableSilentResume) +{ + boost::unique_lock lock(m_lock); + m_bCurrentItemSilentResume = bEnableSilentResume; +} + bool TSubTaskStatsInfo::WasAdded() const { boost::shared_lock lock(m_lock); Index: src/libchcore/TSubTaskStatsInfo.h =================================================================== diff -u -N -r16df8fcf9d5b3317338aece64762771419beaf4a -r79399818d01f20d3a83766543e98ef5f0ee3de38 --- src/libchcore/TSubTaskStatsInfo.h (.../TSubTaskStatsInfo.h) (revision 16df8fcf9d5b3317338aece64762771419beaf4a) +++ src/libchcore/TSubTaskStatsInfo.h (.../TSubTaskStatsInfo.h) (revision 79399818d01f20d3a83766543e98ef5f0ee3de38) @@ -98,6 +98,9 @@ unsigned long long GetCurrentItemProcessedSize() const; unsigned long long GetCurrentItemTotalSize() const; + bool CanCurrentItemSilentResume() const; + void SetCurrentItemSilentResume(bool bEnableSilentResume); + // current index void SetCurrentIndex(file_count_t fcIndex); file_count_t GetCurrentIndex() const; @@ -148,6 +151,7 @@ eMod_SubOperationType, eMod_IsInitialized, eMod_CurrentItemIndex, + eMod_CurrentItemCanResumeSilently, // last item eMod_Last @@ -170,6 +174,7 @@ TSharedModificationTracker m_ullCurrentItemProcessedSize; TSharedModificationTracker m_ullCurrentItemTotalSize; + TSharedModificationTracker m_bCurrentItemSilentResume; mutable TSharedModificationTracker m_tTimer;