| 348 | } |
| 349 | |
| 350 | void OptionsModel::SetPruneTargetGB(int prune_target_gb) |
| 351 | { |
| 352 | const common::SettingsValue cur_value = node().getPersistentSetting("prune"); |
| 353 | const common::SettingsValue new_value = PruneSetting(prune_target_gb > 0, prune_target_gb); |
| 354 | |
| 355 | // Force setting to take effect. It is still safe to change the value at |
| 356 | // this point because this function is only called after the intro screen is |
| 357 | // shown, before the node starts. |
| 358 | node().forceSetting("prune", new_value); |
| 359 | |
| 360 | // Update settings.json if value configured in intro screen is different |
| 361 | // from saved value. Avoid writing settings.json if bitcoin.conf value |
| 362 | // doesn't need to be overridden. |
| 363 | if (PruneEnabled(cur_value) != PruneEnabled(new_value) || |
| 364 | PruneSizeGB(cur_value) != PruneSizeGB(new_value)) { |
| 365 | // Call UpdateRwSetting() instead of setOption() to avoid setting |
| 366 | // RestartRequired flag |
| 367 | UpdateRwSetting(node(), Prune, "", new_value); |
| 368 | } |
| 369 | |
| 370 | // Keep previous pruning size, if pruning was disabled. |
| 371 | if (PruneEnabled(cur_value)) { |
| 372 | UpdateRwSetting(node(), Prune, "-prev", PruneEnabled(new_value) ? common::SettingsValue{} : cur_value); |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | // read QSettings values and return them |
| 377 | QVariant OptionsModel::data(const QModelIndex & index, int role) const |
no test coverage detected