diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-13 17:58:38 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-13 17:58:38 +0000 |
commit | 560b3a231ec9998665982cf8e54fd8aca8bb6b4d (patch) | |
tree | 6f39f40b56c96ad45f7929714d883aecc8247e85 /plugins/Db_autobackups | |
parent | 5e443d39c3162ec6e926849147b8ff898706a97f (diff) |
crash fix for the small database packing
git-svn-id: http://svn.miranda-ng.org/main/trunk@7635 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db_autobackups')
-rw-r--r-- | plugins/Db_autobackups/src/backup.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/plugins/Db_autobackups/src/backup.cpp b/plugins/Db_autobackups/src/backup.cpp index 987c0c144f..37892121e9 100644 --- a/plugins/Db_autobackups/src/backup.cpp +++ b/plugins/Db_autobackups/src/backup.cpp @@ -75,22 +75,22 @@ bool MakeZip(LPCTSTR tszSource, LPCTSTR tszDest) {
DWORD buf_length = 256 * 1024; // 256 KB
HWND hProgBar = GetDlgItem(progress_dialog, IDC_PROGRESS);
- UINT i = 0;
+ DWORD dwTotalBytes = 0;
MSG msg;
if (void* buf = mir_alloc( buf_length ))
{
while (GetWindowLongPtr(progress_dialog, GWLP_USERDATA) != 1)
{
- DWORD read = 0;
- if (!ReadFile( hSrc, buf, buf_length, &read, NULL))
+ DWORD dwRead = 0;
+ if (!ReadFile(hSrc, buf, buf_length, &dwRead, NULL))
break;
- if (read == 0) // EOF
+ if (dwRead == 0) // EOF
{
ret = true;
break;
}
- res = zipWriteInFileInZip(hZip, buf, read);
+ res = zipWriteInFileInZip(hZip, buf, dwRead);
if (res != ZIP_OK)
break;
@@ -102,7 +102,8 @@ bool MakeZip(LPCTSTR tszSource, LPCTSTR tszDest) DispatchMessage(&msg);
}
}
- SendMessage(hProgBar, PBM_SETPOS, (WPARAM)(100 / ((int)fad.nFileSizeLow / buf_length) * ++i), 0);
+ dwTotalBytes += dwRead;
+ SendMessage(hProgBar, PBM_SETPOS, (WPARAM)(100.0 * double(dwRead) / double(fad.nFileSizeLow)), 0);
}
mir_free(buf);
}
@@ -174,7 +175,7 @@ int RotateBackups() while(bf)
{
- if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY){
+ if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
if (FindNextFile(hFind, &FindFileData))
continue;
else break;
@@ -219,9 +220,9 @@ int Backup(TCHAR* backup_filename) TCHAR *backupfolder = Utils_ReplaceVarsT(options.folder);
// ensure the backup folder exists (either create it or return non-zero signifying error)
int err = CreateDirectoryTreeT(backupfolder);
- if (err != ERROR_ALREADY_EXISTS && err != 0) {
+ if (err != ERROR_ALREADY_EXISTS && err != 0)
return 1;
- }
+
SYSTEMTIME st;
GetLocalTime(&st);
GetComputerName(buffer, &size);
|