summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorSergey Tatarinov <tatarinov.sergey@gmail.com>2013-11-12 15:28:35 +0000
committerSergey Tatarinov <tatarinov.sergey@gmail.com>2013-11-12 15:28:35 +0000
commita582e723883bd6ede6e0c910e82cfc4ad23bc161 (patch)
treee17bd98a1665e1f3e9d571bc3e6b710366c76f2a /plugins
parentfa40c2064d5dfca0ce3eaa11a8c5c6868f35619c (diff)
Db_autobackups: some progress bar fixes and cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@6873 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Db_autobackups/src/backup.cpp33
1 files changed, 13 insertions, 20 deletions
diff --git a/plugins/Db_autobackups/src/backup.cpp b/plugins/Db_autobackups/src/backup.cpp
index 8ae4384bac..621cd3e20d 100644
--- a/plugins/Db_autobackups/src/backup.cpp
+++ b/plugins/Db_autobackups/src/backup.cpp
@@ -30,7 +30,7 @@ TCHAR* DoubleSlash(TCHAR *sorce)
{
TCHAR *ret = (TCHAR*)mir_calloc(MAX_PATH);
TCHAR *r, *s;
- for (s = sorce, r = ret; *s && r - ret < MAX_PATH; s++, r++){
+ for (s = sorce, r = ret; *s && r - ret < MAX_PATH - 1; s++, r++){
if (*s != _T('\\'))
*r = *s;
else{
@@ -79,9 +79,10 @@ bool MakeZip(LPCTSTR tszSource, LPCTSTR tszDest)
DWORD buf_length = 256 * 1024; // 256 KB
HWND hProgBar = GetDlgItem(progress_dialog, IDC_PROGRESS);
UINT i = 0;
+ MSG msg;
if ( void* buf = mir_alloc( buf_length ) )
{
- for (;;)
+ while (GetWindowLongPtr(progress_dialog, GWLP_USERDATA) == 0)
{
DWORD read = 0;
if ( ! ReadFile( hSrc, buf, buf_length, &read, NULL ) )
@@ -98,9 +99,16 @@ bool MakeZip(LPCTSTR tszSource, LPCTSTR tszDest)
if ( res != ZIP_OK )
break;
+ while(PeekMessage(&msg, progress_dialog, 0, 0, PM_REMOVE) != 0)
+ {
+ if (!IsDialogMessage(progress_dialog, &msg))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
SendMessage(hProgBar, PBM_SETPOS, (WPARAM)(100 / ((int)fad.nFileSizeLow / buf_length) * ++i), 0);
}
-
mir_free( buf );
}
zipCloseFileInZip( hZip );
@@ -149,12 +157,11 @@ struct FileNameFound_Tag
FILETIME CreationTime;
}FileNameFound;
-int RotateBackups(DWORD start_time)
+int RotateBackups()
{
TCHAR backupfilename1[MAX_PATH] = {0}, backupfolderTmp[MAX_PATH] = {0};
unsigned int i = 0;
HWND hProgBar = GetDlgItem(progress_dialog, IDC_PROGRESS);
- MSG msg;
WIN32_FIND_DATA FindFileData;
@@ -181,17 +188,6 @@ int RotateBackups(DWORD start_time)
_tcscpy(FileNameFound.Name, FindFileData.cFileName);
FileNameFound.CreationTime = FindFileData.ftCreationTime;
}
- while(PeekMessage(&msg, progress_dialog, 0, 0, PM_REMOVE) != 0)
- {
- if (!IsDialogMessage(progress_dialog, &msg))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
-
- SendMessage(hProgBar, PBM_SETPOS, (WPARAM)(100 / options.num_backups * ++i), 0);
- //UpdateWindow(progress_dialog);
}
}
@@ -213,7 +209,6 @@ void BackupThread(void* backup_filename)
int Backup(TCHAR* backup_filename)
{
TCHAR source_file[MAX_PATH] = {0}, dest_file[MAX_PATH] = {0};
- DWORD start_time = GetTickCount();
BOOL bZip = FALSE;
CallService(MS_DB_GETPROFILENAMET, MAX_PATH, (LPARAM)dbname);
@@ -248,11 +243,9 @@ int Backup(TCHAR* backup_filename)
SetDlgItemText(progress_dialog, IDC_PROGRESSMESSAGE, TranslateT("Rotating backup files..."));
}
- RotateBackups(start_time);
+ RotateBackups();
SetDlgItemText(progress_dialog, IDC_PROGRESSMESSAGE, TranslateT("Copying database file..."));
- SendMessage(GetDlgItem(progress_dialog, IDC_PROGRESS), PBM_SETPOS, (WPARAM)0, 0);
- UpdateWindow(progress_dialog);
mir_sntprintf(source_file, MAX_PATH, _T("%s\\%s"), profilePath, dbname);
TCHAR *pathtmp = Utils_ReplaceVarsT(source_file);