Index: src/libchcore/TSQLiteTaskSchema.cpp =================================================================== diff -u -r79399818d01f20d3a83766543e98ef5f0ee3de38 -ra476ced2f2235ee21c69176e88eba1cf7aea861f --- src/libchcore/TSQLiteTaskSchema.cpp (.../TSQLiteTaskSchema.cpp) (revision 79399818d01f20d3a83766543e98ef5f0ee3de38) +++ src/libchcore/TSQLiteTaskSchema.cpp (.../TSQLiteTaskSchema.cpp) (revision a476ced2f2235ee21c69176e88eba1cf7aea861f) @@ -40,6 +40,8 @@ TSerializerVersion tVersion(spDatabase); // if version is 0, then this is the fresh database with (almost) no tables inside + // that's why the initialization always creates the latest version of database, whithout going + // through all the intermediate migrations if(tVersion.GetVersion() == 0) { sqlite::TSQLiteStatement tStatement(spDatabase); @@ -77,21 +79,21 @@ tStatement.Prepare(_T("CREATE TABLE subtask_fastmove(id BIGINT UNIQUE, current_index INT NOT NULL, is_running boolean NOT NULL, is_initialized boolean NOT NULL, total_size BIGINT NOT NULL, processed_size BIGINT NOT NULL, size_speed varchar(1024) NOT NULL, ") _T("total_count BIGINT NOT NULL, processed_count BIGINT NOT NULL, count_speed varchar(1024) NOT NULL, ci_processed_size BIGINT NOT NULL, ci_total_size BIGINT NOT NULL, timer BIGINT NOT NULL, ") - _T("buffer_index INT NOT NULL, current_path varchar(32768) NOT NULL, suboperation_type INT NOT NULL)")); + _T("buffer_index INT NOT NULL, current_path varchar(32768) NOT NULL, ci_silent_resume boolean NOT NULL)")); tStatement.Step(); tStatement.Prepare(_T("CREATE TABLE subtask_delete(id BIGINT UNIQUE, current_index INT NOT NULL, is_running boolean NOT NULL, is_initialized boolean NOT NULL, total_size BIGINT NOT NULL, processed_size BIGINT NOT NULL, size_speed varchar(1024) NOT NULL, ") _T("total_count BIGINT NOT NULL, processed_count BIGINT NOT NULL, count_speed varchar(1024) NOT NULL, ci_processed_size BIGINT NOT NULL, ci_total_size BIGINT NOT NULL, timer BIGINT NOT NULL, ") - _T("buffer_index INT NOT NULL, current_path varchar(32768) NOT NULL, suboperation_type INT NOT NULL)")); + _T("buffer_index INT NOT NULL, current_path varchar(32768) NOT NULL, ci_silent_resume boolean NOT NULL)")); tStatement.Step(); tStatement.Prepare(_T("CREATE TABLE subtask_copymove(id BIGINT UNIQUE, current_index INT NOT NULL, is_running boolean NOT NULL, is_initialized boolean NOT NULL, total_size BIGINT NOT NULL, processed_size BIGINT NOT NULL, size_speed varchar(1024) NOT NULL, ") _T("total_count BIGINT NOT NULL, processed_count BIGINT NOT NULL, count_speed varchar(1024) NOT NULL, ci_processed_size BIGINT NOT NULL, ci_total_size BIGINT NOT NULL, timer BIGINT NOT NULL, ") - _T("buffer_index INT NOT NULL, current_path varchar(32768) NOT NULL, suboperation_type INT NOT NULL)")); + _T("buffer_index INT NOT NULL, current_path varchar(32768) NOT NULL, ci_silent_resume boolean NOT NULL)")); tStatement.Step(); // and finally set the database version to current one - tVersion.SetVersion(1); + tVersion.SetVersion(3); } if (tVersion.GetVersion() == 1) @@ -108,6 +110,68 @@ tVersion.SetVersion(2); } + if (tVersion.GetVersion() == 2) + { + sqlite::TSQLiteStatement tStatement(spDatabase); + + // drop column from fastmove + tStatement.Prepare(_T("CREATE TABLE subtask_fastmove_new(id BIGINT UNIQUE, current_index INT NOT NULL, is_running boolean NOT NULL, is_initialized boolean NOT NULL, total_size BIGINT NOT NULL, processed_size BIGINT NOT NULL, size_speed varchar(1024) NOT NULL, ") + _T("total_count BIGINT NOT NULL, processed_count BIGINT NOT NULL, count_speed varchar(1024) NOT NULL, ci_processed_size BIGINT NOT NULL, ci_total_size BIGINT NOT NULL, timer BIGINT NOT NULL, ") + _T("buffer_index INT NOT NULL, current_path varchar(32768) NOT NULL, ci_silent_resume boolean NOT NULL)")); + tStatement.Step(); + + tStatement.Prepare(_T("INSERT INTO subtask_fastmove_new(id, current_index, is_running, is_initialized, total_size, processed_size, size_speed, ") + _T("total_count, processed_count, count_speed, ci_processed_size, ci_total_size, timer, buffer_index, current_path, ci_silent_resume)") + _T("SELECT id, current_index, is_running, is_initialized, total_size, processed_size, size_speed, ") + _T("total_count, processed_count, count_speed, ci_processed_size, ci_total_size, timer, buffer_index, current_path, ci_silent_resume ") + _T("FROM subtask_fastmove")); + tStatement.Step(); + + tStatement.Prepare(_T("DROP TABLE subtask_fastmove")); + tStatement.Step(); + + tStatement.Prepare(_T("ALTER TABLE subtask_fastmove_new RENAME TO subtask_fastmove")); + tStatement.Step(); + + // drop column from subtask delete + tStatement.Prepare(_T("CREATE TABLE subtask_delete_new(id BIGINT UNIQUE, current_index INT NOT NULL, is_running boolean NOT NULL, is_initialized boolean NOT NULL, total_size BIGINT NOT NULL, processed_size BIGINT NOT NULL, size_speed varchar(1024) NOT NULL, ") + _T("total_count BIGINT NOT NULL, processed_count BIGINT NOT NULL, count_speed varchar(1024) NOT NULL, ci_processed_size BIGINT NOT NULL, ci_total_size BIGINT NOT NULL, timer BIGINT NOT NULL, ") + _T("buffer_index INT NOT NULL, current_path varchar(32768) NOT NULL, ci_silent_resume boolean NOT NULL)")); + tStatement.Step(); + + //id, current_index, is_running, is_initialized, total_size, processed_size, size_speed, total_count, processed_count, count_speed, ci_processed_size, ci_total_size, timer, buffer_index, current_path, ci_silent_resume + tStatement.Prepare(_T("INSERT INTO subtask_delete_new(id, current_index, is_running, is_initialized, total_size, processed_size, size_speed, total_count, processed_count, count_speed, ci_processed_size, ci_total_size, timer, buffer_index, current_path, ci_silent_resume)") + _T("SELECT id, current_index, is_running, is_initialized, total_size, processed_size, size_speed, total_count, processed_count, count_speed, ci_processed_size, ci_total_size, timer, buffer_index, current_path, ci_silent_resume ") + _T("FROM subtask_delete")); + tStatement.Step(); + + tStatement.Prepare(_T("DROP TABLE subtask_delete")); + tStatement.Step(); + + tStatement.Prepare(_T("ALTER TABLE subtask_delete_new RENAME TO subtask_delete")); + tStatement.Step(); + + // drop column from subtask copymove + tStatement.Prepare(_T("CREATE TABLE subtask_copymove_new(id BIGINT UNIQUE, current_index INT NOT NULL, is_running boolean NOT NULL, is_initialized boolean NOT NULL, total_size BIGINT NOT NULL, processed_size BIGINT NOT NULL, size_speed varchar(1024) NOT NULL, ") + _T("total_count BIGINT NOT NULL, processed_count BIGINT NOT NULL, count_speed varchar(1024) NOT NULL, ci_processed_size BIGINT NOT NULL, ci_total_size BIGINT NOT NULL, timer BIGINT NOT NULL, ") + _T("buffer_index INT NOT NULL, current_path varchar(32768) NOT NULL, ci_silent_resume boolean NOT NULL)")); + tStatement.Step(); + + //id, current_index, is_running, is_initialized, total_size, processed_size, size_speed, total_count, processed_count, count_speed, ci_processed_size, ci_total_size, timer, buffer_index, current_path, ci_silent_resume + tStatement.Prepare(_T("INSERT INTO subtask_copymove_new(id, current_index, is_running, is_initialized, total_size, processed_size, size_speed, total_count, processed_count, count_speed, ci_processed_size, ci_total_size, timer, buffer_index, current_path, ci_silent_resume)") + _T("SELECT id, current_index, is_running, is_initialized, total_size, processed_size, size_speed, total_count, processed_count, count_speed, ci_processed_size, ci_total_size, timer, buffer_index, current_path, ci_silent_resume ") + _T("FROM subtask_copymove")); + tStatement.Step(); + + tStatement.Prepare(_T("DROP TABLE subtask_copymove")); + tStatement.Step(); + + tStatement.Prepare(_T("ALTER TABLE subtask_copymove_new RENAME TO subtask_copymove")); + tStatement.Step(); + + tVersion.SetVersion(3); + } + tTransaction.Commit(); } Index: src/libchcore/TSubTaskCopyMove.cpp =================================================================== diff -u -r7d59ab9183c933f2fc2682a95fb5d26cf2f952d7 -ra476ced2f2235ee21c69176e88eba1cf7aea861f --- src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 7d59ab9183c933f2fc2682a95fb5d26cf2f952d7) +++ src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision a476ced2f2235ee21c69176e88eba1cf7aea861f) @@ -63,9 +63,9 @@ // class TSubTaskCopyMove TSubTaskCopyMove::TSubTaskCopyMove(TSubTaskContext& tSubTaskContext) : - TSubTaskBase(tSubTaskContext) + TSubTaskBase(tSubTaskContext), + m_tSubTaskStats(eSubOperation_Copying) { - m_tSubTaskStats.SetSubOperationType(eSubOperation_Copying); } void TSubTaskCopyMove::Reset() Index: src/libchcore/TSubTaskDelete.cpp =================================================================== diff -u -r7d59ab9183c933f2fc2682a95fb5d26cf2f952d7 -ra476ced2f2235ee21c69176e88eba1cf7aea861f --- src/libchcore/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision 7d59ab9183c933f2fc2682a95fb5d26cf2f952d7) +++ src/libchcore/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision a476ced2f2235ee21c69176e88eba1cf7aea861f) @@ -45,9 +45,9 @@ // class TSubTaskDelete TSubTaskDelete::TSubTaskDelete(TSubTaskContext& rContext) : - TSubTaskBase(rContext) + TSubTaskBase(rContext), + m_tSubTaskStats(eSubOperation_Deleting) { - m_tSubTaskStats.SetSubOperationType(eSubOperation_Deleting); } void TSubTaskDelete::Reset() Index: src/libchcore/TSubTaskFastMove.cpp =================================================================== diff -u -r7d59ab9183c933f2fc2682a95fb5d26cf2f952d7 -ra476ced2f2235ee21c69176e88eba1cf7aea861f --- src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision 7d59ab9183c933f2fc2682a95fb5d26cf2f952d7) +++ src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision a476ced2f2235ee21c69176e88eba1cf7aea861f) @@ -43,9 +43,9 @@ BEGIN_CHCORE_NAMESPACE TSubTaskFastMove::TSubTaskFastMove(TSubTaskContext& rContext) : - TSubTaskBase(rContext) + TSubTaskBase(rContext), + m_tSubTaskStats(eSubOperation_FastMove) { - m_tSubTaskStats.SetSubOperationType(eSubOperation_FastMove); } TSubTaskFastMove::~TSubTaskFastMove() Index: src/libchcore/TSubTaskScanDirectory.cpp =================================================================== diff -u -r7d59ab9183c933f2fc2682a95fb5d26cf2f952d7 -ra476ced2f2235ee21c69176e88eba1cf7aea861f --- src/libchcore/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision 7d59ab9183c933f2fc2682a95fb5d26cf2f952d7) +++ src/libchcore/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision a476ced2f2235ee21c69176e88eba1cf7aea861f) @@ -45,9 +45,9 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// // class TSubTaskScanDirectories TSubTaskScanDirectories::TSubTaskScanDirectories(TSubTaskContext& rContext) : - TSubTaskBase(rContext) + TSubTaskBase(rContext), + m_tSubTaskStats(eSubOperation_Scanning) { - m_tSubTaskStats.SetSubOperationType(eSubOperation_Scanning); } TSubTaskScanDirectories::~TSubTaskScanDirectories() Index: src/libchcore/TSubTaskStatsInfo.cpp =================================================================== diff -u -r7d59ab9183c933f2fc2682a95fb5d26cf2f952d7 -ra476ced2f2235ee21c69176e88eba1cf7aea861f --- src/libchcore/TSubTaskStatsInfo.cpp (.../TSubTaskStatsInfo.cpp) (revision 7d59ab9183c933f2fc2682a95fb5d26cf2f952d7) +++ src/libchcore/TSubTaskStatsInfo.cpp (.../TSubTaskStatsInfo.cpp) (revision a476ced2f2235ee21c69176e88eba1cf7aea861f) @@ -34,7 +34,8 @@ /////////////////////////////////////////////////////////////////////////////////// // class TSubTaskStatsInfo -TSubTaskStatsInfo::TSubTaskStatsInfo() : +TSubTaskStatsInfo::TSubTaskStatsInfo(ESubOperationType eSubTaskType) : + m_eSubOperationType(eSubTaskType), m_bSubTaskIsRunning(m_setModifications, false), m_ullTotalSize(m_setModifications, 0), m_ullProcessedSize(m_setModifications, 0), @@ -46,7 +47,6 @@ m_tCountSpeed(m_setModifications, DefaultSpeedTrackTime, DefaultSpeedSampleTime), m_ullCurrentItemProcessedSize(m_setModifications, 0), m_ullCurrentItemTotalSize(m_setModifications, 0), - m_eSubOperationType(m_setModifications, eSubOperation_None), m_tTimer(m_setModifications), m_bIsInitialized(m_setModifications, false), m_fcCurrentIndex(m_setModifications, 0), @@ -69,7 +69,6 @@ m_tCountSpeed.Modify().Clear(); m_ullCurrentItemProcessedSize = 0; m_ullCurrentItemTotalSize = 0; - m_eSubOperationType = eSubOperation_None; m_bIsInitialized = false; m_fcCurrentIndex = 0; m_bCurrentItemSilentResume = false; @@ -313,8 +312,6 @@ if(m_strCurrentPath.IsModified()) rRowData.SetValue(_T("current_path"), m_strCurrentPath); - if(m_eSubOperationType.IsModified()) - rRowData.SetValue(_T("suboperation_type"), m_eSubOperationType); m_setModifications.reset(); } @@ -337,7 +334,6 @@ rColumnDefs.AddColumn(_T("timer"), IColumnsDefinition::eType_ulonglong); rColumnDefs.AddColumn(_T("buffer_index"), IColumnsDefinition::eType_int); rColumnDefs.AddColumn(_T("current_path"), IColumnsDefinition::eType_string); - rColumnDefs.AddColumn(_T("suboperation_type"), IColumnsDefinition::eType_int); } void TSubTaskStatsInfo::Load(const ISerializerRowReaderPtr& spRowReader) @@ -373,7 +369,6 @@ spRowReader->GetValue(_T("buffer_index"), m_iCurrentBufferIndex.Modify()); spRowReader->GetValue(_T("current_path"), m_strCurrentPath.Modify()); - spRowReader->GetValue(_T("suboperation_type"), *(int*)&m_eSubOperationType.Modify()); m_setModifications.reset(); } Index: src/libchcore/TSubTaskStatsInfo.h =================================================================== diff -u -r7d59ab9183c933f2fc2682a95fb5d26cf2f952d7 -ra476ced2f2235ee21c69176e88eba1cf7aea861f --- src/libchcore/TSubTaskStatsInfo.h (.../TSubTaskStatsInfo.h) (revision 7d59ab9183c933f2fc2682a95fb5d26cf2f952d7) +++ src/libchcore/TSubTaskStatsInfo.h (.../TSubTaskStatsInfo.h) (revision a476ced2f2235ee21c69176e88eba1cf7aea861f) @@ -48,7 +48,7 @@ static const unsigned long long DefaultSpeedSampleTime = 100; // in miliseconds public: - TSubTaskStatsInfo(); + TSubTaskStatsInfo(ESubOperationType eSubTaskType); void Init(int iCurrentBufferIndex, file_count_t fcTotalCount, file_count_t fcProcessedCount, unsigned long long ullTotalSize, unsigned long long ullProcessedSize, const TString& strCurrentPath); void Clear(); @@ -98,7 +98,6 @@ void SetCurrentPath(const TString& strPath); ESubOperationType GetSubOperationType() const { return m_eSubOperationType; } - void SetSubOperationType(ESubOperationType val) { m_eSubOperationType = val; } // serialization void Store(ISerializerRowData& rRowData) const; @@ -135,7 +134,6 @@ eMod_Timer, eMod_CurrentBufferIndex, eMod_CurrentPath, - eMod_SubOperationType, eMod_IsInitialized, eMod_CurrentItemIndex, eMod_CurrentItemCanResumeSilently, @@ -169,10 +167,10 @@ TSharedModificationTracker m_strCurrentPath; // currently processed path - TSharedModificationTracker m_eSubOperationType; - TSharedModificationTracker m_bIsInitialized; + const ESubOperationType m_eSubOperationType; + #pragma warning(push) #pragma warning(disable: 4251) mutable boost::shared_mutex m_lock;