temporary fix: data/log dir looks weired after local pair sync (#3159)

This commit is contained in:
frank 2023-02-06 17:55:41 +08:00 committed by GitHub
parent 03c61e8847
commit 5ea8906dda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"path/filepath"
"strings"
"github.com/google/uuid"
@ -79,7 +80,17 @@ func (s *SyncRawMessageHandler) PrepareRawMessage(keyUID string) ([]byte, error)
if err != nil {
return nil, err
}
nodeConfig := s.backend.StatusNode().Config()
dataDir := nodeConfig.DataDir
disabledDataDir := nodeConfig.ShhextConfig.BackupDisabledDataDir
defer func() {
// restore data dir
nodeConfig.DataDir = dataDir
nodeConfig.ShhextConfig.BackupDisabledDataDir = disabledDataDir
}()
nodeConfig.DataDir = strings.Replace(dataDir, nodeConfig.RootDataDir, "", 1)
nodeConfig.ShhextConfig.BackupDisabledDataDir = strings.Replace(disabledDataDir, nodeConfig.RootDataDir, "", 1)
if syncRawMessage.NodeConfigJsonBytes, err = json.Marshal(nodeConfig); err != nil {
return nil, err
}
@ -99,13 +110,17 @@ func (s *SyncRawMessageHandler) HandleRawMessage(account *multiaccounts.Account,
return err
}
//TODO root data dir should be passed from client, following is a temporary solution
nodeConfig.RootDataDir = filepath.Dir(keystorePath)
nodeConfig.DataDir = filepath.Join(nodeConfig.RootDataDir, filepath.Base(nodeConfig.DataDir))
nodeConfig.KeyStoreDir = newKeystoreDir
nodeConfig.KeyStoreDir = filepath.Join(filepath.Base(keystorePath), account.KeyUID)
installationID := uuid.New().String()
nodeConfig.ShhextConfig.InstallationID = installationID
setting.InstallationID = installationID
//TODO we need a better way(e.g. pass from client when doing local pair?) to handle this, following is a temporary solution
nodeConfig.LogDir = nodeConfig.RootDataDir
nodeConfig.LogFile = "geth.log"
err = s.backend.StartNodeWithAccountAndInitialConfig(*account, password, *setting, nodeConfig, subAccounts)
if err != nil {
return err