diff options
author | George Hazan <ghazan@miranda.im> | 2021-03-31 15:56:51 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-03-31 15:56:51 +0300 |
commit | 94d7f064022edad1e228a2f8c3076f6c609a776f (patch) | |
tree | 98fbdac183e01181ec233cff5ccc1ca10e4f3dff | |
parent | 5f7acbc21e1809e8f6afb3c98302a474a530113e (diff) |
for #2811: added reaction to period type change too
-rw-r--r-- | plugins/Db_autobackups/src/backup.cpp | 10 | ||||
-rw-r--r-- | plugins/Db_autobackups/src/options.cpp | 11 |
2 files changed, 18 insertions, 3 deletions
diff --git a/plugins/Db_autobackups/src/backup.cpp b/plugins/Db_autobackups/src/backup.cpp index dea8d01c97..1ac63a7bab 100644 --- a/plugins/Db_autobackups/src/backup.cpp +++ b/plugins/Db_autobackups/src/backup.cpp @@ -324,7 +324,15 @@ VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD) {
time_t t = time(0);
time_t diff = t - (time_t)g_plugin.getDword("LastBackupTimestamp");
- if (diff > time_t(g_plugin.period) * (g_plugin.period_type == PT_MINUTES ? 60 : (g_plugin.period_type == PT_HOURS ? (60 * 60) : (60 * 60 * 24))))
+
+ int iMultiplicator;
+ switch (g_plugin.period_type) {
+ case PT_MINUTES: iMultiplicator = 60; break;
+ case PT_HOURS: iMultiplicator = 3600; break;
+ default: iMultiplicator = 86400; break; // days
+ }
+
+ if (diff > time_t(g_plugin.period) * iMultiplicator)
BackupStart(nullptr);
}
diff --git a/plugins/Db_autobackups/src/options.cpp b/plugins/Db_autobackups/src/options.cpp index 79aa228e57..d0688efd59 100644 --- a/plugins/Db_autobackups/src/options.cpp +++ b/plugins/Db_autobackups/src/options.cpp @@ -148,7 +148,7 @@ public: m_backupOnStart.OnChange = m_backupOnExit.OnChange = m_backupPeriodic.OnChange = Callback(this, &COptionsDlg::onChange_BackupType);
m_useCloudFile.OnChange = Callback(this, &COptionsDlg::onChange_UseCloudFile);
m_useZip.OnChange = Callback(this, &COptionsDlg::onChange_UseZip);
- m_period.OnChange = Callback(this, &COptionsDlg::onChange_Period);
+ m_periodType.OnSelChanged = m_period.OnChange = Callback(this, &COptionsDlg::onChange_Period);
m_backup.OnClick = Callback(this, &COptionsDlg::onClick_Backup);
m_browseFolder.OnClick = Callback(this, &COptionsDlg::onClick_BrowseFolder);
@@ -271,7 +271,14 @@ public: void onChange_Period(CCtrlSpin*)
{
- time_t nextBackup = time_t(g_plugin.getDword("LastBackupTimestamp")) + m_period.GetPosition() * 86400;
+ int iMultiplicator;
+ switch (m_periodType.GetCurSel()) {
+ case PT_MINUTES: iMultiplicator = 60; break;
+ case PT_HOURS: iMultiplicator = 3600; break;
+ default: iMultiplicator = 86400; break; // days
+ }
+
+ time_t nextBackup = time_t(g_plugin.getDword("LastBackupTimestamp")) + m_period.GetPosition() * iMultiplicator;
wchar_t buf[100];
TimeZone_PrintTimeStamp(nullptr, nextBackup, L"D t", buf, _countof(buf), 0);
|