mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-20 23:27:23 +00:00
Allow updating some database settings.
This commit is contained in:
parent
55fe977d54
commit
5733f4079f
@ -22,6 +22,12 @@ void Database::reconfigure(const Settings &settings) {
|
||||
});
|
||||
}
|
||||
|
||||
void Database::updateSettings(const SettingsUpdate &update) {
|
||||
_wrapped.with([update](Implementation &unwrapped) mutable {
|
||||
unwrapped.updateSettings(update);
|
||||
});
|
||||
}
|
||||
|
||||
void Database::open(EncryptionKey &&key, FnMut<void(Error)> &&done) {
|
||||
_wrapped.with([
|
||||
key = std::move(key),
|
||||
|
@ -24,9 +24,11 @@ class DatabaseObject;
|
||||
class Database {
|
||||
public:
|
||||
using Settings = details::Settings;
|
||||
using SettingsUpdate = details::SettingsUpdate;
|
||||
Database(const QString &path, const Settings &settings);
|
||||
|
||||
void reconfigure(const Settings &settings);
|
||||
void updateSettings(const SettingsUpdate &update);
|
||||
|
||||
void open(EncryptionKey &&key, FnMut<void(Error)> &&done = nullptr);
|
||||
void close(FnMut<void()> &&done = nullptr);
|
||||
|
@ -92,6 +92,14 @@ void DatabaseObject::reconfigure(const Settings &settings) {
|
||||
checkSettings();
|
||||
}
|
||||
|
||||
void DatabaseObject::updateSettings(const SettingsUpdate &update) {
|
||||
_settings.totalSizeLimit = update.totalSizeLimit;
|
||||
_settings.totalTimeLimit = update.totalTimeLimit;
|
||||
checkSettings();
|
||||
|
||||
optimize();
|
||||
}
|
||||
|
||||
void DatabaseObject::checkSettings() {
|
||||
Expects(_settings.staleRemoveChunk > 0);
|
||||
Expects(_settings.maxDataSize > 0
|
||||
|
@ -31,6 +31,7 @@ public:
|
||||
const QString &path,
|
||||
const Settings &settings);
|
||||
void reconfigure(const Settings &settings);
|
||||
void updateSettings(const SettingsUpdate &update);
|
||||
|
||||
void open(EncryptionKey &&key, FnMut<void(Error)> &&done);
|
||||
void close(FnMut<void()> &&done);
|
||||
|
@ -66,13 +66,18 @@ struct Settings {
|
||||
|
||||
bool trackEstimatedTime = true;
|
||||
int64 totalSizeLimit = 1024 * 1024 * 1024;
|
||||
size_type totalTimeLimit = 30 * 86400; // One month in seconds.
|
||||
size_type totalTimeLimit = 31 * 24 * 60 * 60; // One month in seconds.
|
||||
crl::time_type pruneTimeout = 5 * crl::time_type(1000);
|
||||
crl::time_type maxPruneCheckTimeout = 3600 * crl::time_type(1000);
|
||||
|
||||
bool clearOnWrongKey = false;
|
||||
};
|
||||
|
||||
struct SettingsUpdate {
|
||||
int64 totalSizeLimit = Settings().totalSizeLimit;
|
||||
size_type totalTimeLimit = Settings().totalTimeLimit;
|
||||
};
|
||||
|
||||
struct TaggedValue {
|
||||
TaggedValue() = default;
|
||||
TaggedValue(QByteArray &&bytes, uint8 tag);
|
||||
|
Loading…
Reference in New Issue
Block a user