Skip to content

Commit

Permalink
[status-im/status-mobile#9942] Upgradable paths in configs
Browse files Browse the repository at this point in the history
Storing absolute path for different configs breaks compatibility on iOS
as app's dir is changed after upgrade. The solution is to store relative
paths and to concatenate it with `backend.rootDataDir`. The only
exception is `LogFile` as it is stored outside `backend.rootDataDir` on
Android. `LogDir` config was added to allow adding of custom dir for log
file.
Configs concerned:
`DataDir`
`LogDir`
`LogFile`
`KeystoreDir`
`BackupDisabledDataDir`
  • Loading branch information
rasom committed Feb 3, 2020
1 parent c2f22f1 commit ae9c559
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/geth_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ func (b *GethStatusBackend) startNodeWithKey(acc multiaccounts.Account, password
if err != nil {
return err
}

if err := logutils.OverrideRootLogWithConfig(conf, false); err != nil {
return err
}
Expand Down Expand Up @@ -372,6 +373,15 @@ func (b *GethStatusBackend) loadNodeConfig() (*params.NodeConfig, error) {
// which is set at the compile time.
// What's cached is usually outdated so we overwrite it here.
conf.Version = params.Version
conf.DataDir = filepath.Join(b.rootDataDir, conf.DataDir)
conf.ShhextConfig.BackupDisabledDataDir = filepath.Join(b.rootDataDir, conf.ShhextConfig.BackupDisabledDataDir)
if len(conf.LogDir) == 0 {
conf.LogFile = filepath.Join(b.rootDataDir, conf.LogFile)
} else {
conf.LogFile = filepath.Join(conf.LogDir, conf.LogFile)
}
conf.KeyStoreDir = filepath.Join(b.rootDataDir, conf.KeyStoreDir)

return &conf, nil
}

Expand Down
11 changes: 11 additions & 0 deletions api/nimbus_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,17 @@ func (b *nimbusStatusBackend) loadNodeConfig() (*params.NodeConfig, error) {
// which is set at the compile time.
// What's cached is usually outdated so we overwrite it here.
conf.Version = params.Version

// Replace all relative paths with absolute
conf.DataDir = filepath.Join(b.rootDataDir, conf.DataDir)
conf.ShhextConfig.BackupDisabledDataDir = filepath.Join(b.rootDataDir, conf.ShhextConfig.BackupDisabledDataDir)
if len(conf.LogDir) == 0 {
conf.LogFile = filepath.Join(b.rootDataDir, conf.LogFile)
} else {
conf.LogFile = filepath.Join(conf.LogDir, conf.LogFile)
}
conf.KeyStoreDir = filepath.Join(b.rootDataDir, conf.KeyStoreDir)

return &conf, nil
}

Expand Down
3 changes: 3 additions & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ type NodeConfig struct {
// LogMobileSystem enables log redirection to android/ios system logger.
LogMobileSystem bool

// LogFile is a folder which contains LogFile
LogDir string

// LogFile is filename where exposed logs get written to
LogFile string

Expand Down

0 comments on commit ae9c559

Please sign in to comment.