1
0
Эх сурвалжийг харах

delete all clip data before compact and repair

git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@674 595ec19a-5cb4-439b-94a8-42fb3063c22c
sabrogden 12 жил өмнө
parent
commit
2b6fe2f807

+ 2 - 2
DatabaseUtilities.cpp

@@ -551,7 +551,7 @@ BOOL RepairDatabase()
 	return TRUE;
 }
 
-BOOL RemoveOldEntries()
+BOOL RemoveOldEntries(bool checkIdleTime)
 {
 	Log(StrF(_T("Beginning of RemoveOldEntries MaxEntries: %d - Keep days: %d"), CGetSetOptions::GetMaxEntries(), CGetSetOptions::GetExpiredEntries()));
 
@@ -639,7 +639,7 @@ BOOL RemoveOldEntries()
 		while(q.eof() == false)
 		{
 			double idleSeconds = IdleSeconds();
-			if(idleSeconds > CGetSetOptions::GetIdleSecondsBeforeDelete())
+			if(checkIdleTime == false || idleSeconds > CGetSetOptions::GetIdleSecondsBeforeDelete())
 			{
 				//delete any data items sitting out there that the main table data was deleted
 				//this was done to speed up deleted from the main table

+ 1 - 1
DatabaseUtilities.h

@@ -23,7 +23,7 @@ BOOL CreateDB(CString csPath);
 
 BOOL CompactDatabase();
 BOOL RepairDatabase();
-BOOL RemoveOldEntries();
+BOOL RemoveOldEntries(bool checkIdleTime);
 
 BOOL EnsureDirectory(CString csPath);
 

+ 1 - 1
MainFrmThread.cpp

@@ -67,7 +67,7 @@ void CMainFrmThread::OnEvent(int eventId, void *param)
 
 void CMainFrmThread::OnDeleteEntries()
 {
-    RemoveOldEntries();
+    RemoveOldEntries(true);
 }
 
 void CMainFrmThread::OnRemoveRemoteFiles()

+ 13 - 0
OptionsGeneral.cpp

@@ -320,6 +320,19 @@ void COptionsGeneral::OnBtCompactAndRepair()
 
 	try
 	{
+		try
+		{
+			for(int i = 0; i < 100; i++)
+			{
+				int toDeleteCount = theApp.m_db.execScalar(_T("SELECT COUNT(clipID) FROM MainDeletes"));
+				if(toDeleteCount <= 0)
+					break;
+
+				RemoveOldEntries(false);
+			}
+		}
+		CATCH_SQLITE_EXCEPTION
+
 		theApp.m_db.execDML(_T("PRAGMA auto_vacuum = 1"));
 		theApp.m_db.execQuery(_T("VACUUM"));
 	}