Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 265aed95 authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #8076 from thunderbird/refactor_Settings_upgrade

Refactor `Settings.upgrade()`
parents d92ee6b1 b0bb33da
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -303,7 +303,7 @@ public class AccountSettingsDescriptions {
        return Settings.validate(version, SETTINGS, importedSettings, useDefaultValues);
    }

    public static Set<String> upgrade(int version, Map<String, Object> validatedSettings) {
    public static Map<String, Object> upgrade(int version, Map<String, Object> validatedSettings) {
        return Settings.upgrade(version, UPGRADERS, SETTINGS, validatedSettings);
    }

+3 −4
Original line number Diff line number Diff line
@@ -6,13 +6,12 @@ internal class AccountSettingsUpgrader {
    private val serverSettingsUpgrader = ServerSettingsUpgrader()

    fun upgrade(contentVersion: Int, account: ValidatedSettings.Account): ValidatedSettings.Account {
        val validatedSettings = account.settings.toMutableMap()
        if (contentVersion != Settings.VERSION) {
            AccountSettingsDescriptions.upgrade(contentVersion, validatedSettings)
        if (contentVersion == Settings.VERSION) {
            return account
        }

        return account.copy(
            settings = validatedSettings.toMap(),
            settings = AccountSettingsDescriptions.upgrade(contentVersion, account.settings),
            incoming = serverSettingsUpgrader.upgrade(contentVersion, account.incoming),
            outgoing = serverSettingsUpgrader.upgrade(contentVersion, account.outgoing),
            identities = upgradeIdentities(contentVersion, account.identities),
+1 −2
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

import com.fsck.k9.mail.FolderClass;
@@ -59,7 +58,7 @@ class FolderSettingsDescriptions {
        return Settings.validate(version, SETTINGS, importedSettings, useDefaultValues);
    }

    public static Set<String> upgrade(int version, Map<String, Object> validatedSettings) {
    public static Map<String, Object> upgrade(int version, Map<String, Object> validatedSettings) {
        return Settings.upgrade(version, UPGRADERS, SETTINGS, validatedSettings);
    }

+5 −4
Original line number Diff line number Diff line
@@ -2,11 +2,12 @@ package com.fsck.k9.preferences

internal class FolderSettingsUpgrader {
    fun upgrade(contentVersion: Int, folder: ValidatedSettings.Folder): ValidatedSettings.Folder {
        val settings = folder.settings.toMutableMap()
        if (contentVersion != Settings.VERSION) {
            FolderSettingsDescriptions.upgrade(contentVersion, settings)
        if (contentVersion == Settings.VERSION) {
            return folder
        }

        return folder.copy(settings = settings.toMap())
        val upgradedSettings = FolderSettingsDescriptions.upgrade(contentVersion, folder.settings)

        return folder.copy(settings = upgradedSettings)
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

import android.content.Context;
@@ -317,7 +316,7 @@ public class GeneralSettingsDescriptions {
        return Settings.validate(version, SETTINGS, importedSettings, false);
    }

    public static Set<String> upgrade(int version, Map<String, Object> validatedSettings) {
    public static Map<String, Object> upgrade(int version, Map<String, Object> validatedSettings) {
        return Settings.upgrade(version, UPGRADERS, SETTINGS, validatedSettings);
    }

Loading