chore_: remove deprecated `CreateAccount.BackupDisabledDataDir` (#5664)
* chore_: remove deprecated CreateAccount.BackupDisabledDataDir * test_: cover ErrCreateAccountInvalidRootDataDir
This commit is contained in:
parent
2f5437130e
commit
eeb34f780f
|
@ -1737,11 +1737,11 @@ func TestRestoreAccountAndLogin(t *testing.T) {
|
||||||
Mnemonic: "test test test test test test test test test test test test",
|
Mnemonic: "test test test test test test test test test test test test",
|
||||||
FetchBackup: false,
|
FetchBackup: false,
|
||||||
CreateAccount: requests.CreateAccount{
|
CreateAccount: requests.CreateAccount{
|
||||||
DisplayName: "Account1",
|
DisplayName: "Account1",
|
||||||
DeviceName: "StatusIM",
|
DeviceName: "StatusIM",
|
||||||
Password: "password",
|
Password: "password",
|
||||||
CustomizationColor: "0x000000",
|
CustomizationColor: "0x000000",
|
||||||
BackupDisabledDataDir: tmpdir,
|
RootDataDir: tmpdir,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
account, err := backend.RestoreAccountAndLogin(restoreRequest)
|
account, err := backend.RestoreAccountAndLogin(restoreRequest)
|
||||||
|
@ -1778,10 +1778,8 @@ func TestCreateAccountPathsValidation(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
request.RootDataDir = ""
|
request.RootDataDir = ""
|
||||||
request.BackupDisabledDataDir = tmpdir
|
|
||||||
err = request.Validate(validation)
|
err = request.Validate(validation)
|
||||||
require.NoError(t, err)
|
require.ErrorIs(t, err, requests.ErrCreateAccountInvalidRootDataDir)
|
||||||
require.Equal(t, tmpdir, request.RootDataDir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRestoreKeycardAccountAndLogin(t *testing.T) {
|
func TestRestoreKeycardAccountAndLogin(t *testing.T) {
|
||||||
|
|
|
@ -204,11 +204,11 @@ func main() {
|
||||||
Mnemonic: *seedPhrase,
|
Mnemonic: *seedPhrase,
|
||||||
FetchBackup: false,
|
FetchBackup: false,
|
||||||
CreateAccount: requests.CreateAccount{
|
CreateAccount: requests.CreateAccount{
|
||||||
DisplayName: "Account1",
|
DisplayName: "Account1",
|
||||||
DeviceName: "StatusIM",
|
DeviceName: "StatusIM",
|
||||||
Password: *password,
|
Password: *password,
|
||||||
CustomizationColor: "0x000000",
|
CustomizationColor: "0x000000",
|
||||||
BackupDisabledDataDir: config.DataDir,
|
RootDataDir: config.DataDir,
|
||||||
APIConfig: &requests.APIConfig{
|
APIConfig: &requests.APIConfig{
|
||||||
ConnectorEnabled: config.ClusterConfig.Enabled,
|
ConnectorEnabled: config.ClusterConfig.Enabled,
|
||||||
HTTPEnabled: config.HTTPEnabled,
|
HTTPEnabled: config.HTTPEnabled,
|
||||||
|
|
|
@ -33,10 +33,6 @@ type APIConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateAccount struct {
|
type CreateAccount struct {
|
||||||
// Deprecated: BackupDisabledDataDir is the directory where backup is disabled
|
|
||||||
// Use `RootDataDir` instead. Effective BackupDisabledDataDir value will default to RootDataDir + "./".
|
|
||||||
BackupDisabledDataDir string `json:"backupDisabledDataDir"`
|
|
||||||
|
|
||||||
// RootDataDir is an absolute path to the root directory where all data will be stored.
|
// RootDataDir is an absolute path to the root directory where all data will be stored.
|
||||||
RootDataDir string `json:"rootDataDir"`
|
RootDataDir string `json:"rootDataDir"`
|
||||||
KdfIterations int `json:"kdfIterations"`
|
KdfIterations int `json:"kdfIterations"`
|
||||||
|
@ -134,13 +130,7 @@ func (c *CreateAccount) Validate(validation *CreateAccountValidation) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(c.RootDataDir) == 0 {
|
if len(c.RootDataDir) == 0 {
|
||||||
if c.BackupDisabledDataDir == "" {
|
return ErrCreateAccountInvalidRootDataDir
|
||||||
return ErrCreateAccountInvalidRootDataDir
|
|
||||||
}
|
|
||||||
// NOTE: Fallback to old BackupDisabledDataDir field.
|
|
||||||
// Remove this when both desktop and mobile use the new `RootDataDir` field.
|
|
||||||
// Return error if `RootDataDir` is empty.
|
|
||||||
c.RootDataDir = c.BackupDisabledDataDir
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue