From 5ea8906ddaf72f352dd9b602f2f35565f77a6c14 Mon Sep 17 00:00:00 2001 From: frank Date: Mon, 6 Feb 2023 17:55:41 +0800 Subject: [PATCH] temporary fix: data/log dir looks weired after local pair sync (#3159) --- server/pairing/raw_message_handler.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/server/pairing/raw_message_handler.go b/server/pairing/raw_message_handler.go index 90b7307ef..7d9f08f37 100644 --- a/server/pairing/raw_message_handler.go +++ b/server/pairing/raw_message_handler.go @@ -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