From 0ba4694f21ae2ebdacf4ba5305397293c7058303 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Fri, 25 Sep 2020 09:31:55 +0200 Subject: [PATCH] [Fix: #2027] Migrate db to shorter path name --- VERSION | 2 +- api/backend_test.go | 2 +- api/geth_backend.go | 19 +++++++++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index eb324e6fd..7b859acb9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.62.3 +0.62.4 diff --git a/api/backend_test.go b/api/backend_test.go index d36b50a71..552f24f76 100644 --- a/api/backend_test.go +++ b/api/backend_test.go @@ -191,7 +191,7 @@ func TestBackendAccountsConcurrently(t *testing.T) { assert.NoError(t, err) addressCh <- [...]string{accountInfo.WalletAddress, accountInfo.ChatAddress, pass} wgCreateAccounts.Done() - }("password-00" + string(i)) + }("password-00" + fmt.Sprint(i)) } // close addressCh as otherwise for loop never finishes diff --git a/api/geth_backend.go b/api/geth_backend.go index 05e158bd3..a6cc0fe02 100644 --- a/api/geth_backend.go +++ b/api/geth_backend.go @@ -196,6 +196,9 @@ func (b *GethStatusBackend) DeleteMulticcount(keyUID string, keyStoreDir string) filepath.Join(b.rootDataDir, fmt.Sprintf("app-%x.sql", keyUID)), filepath.Join(b.rootDataDir, fmt.Sprintf("app-%x.sql-shm", keyUID)), filepath.Join(b.rootDataDir, fmt.Sprintf("app-%x.sql-wal", keyUID)), + filepath.Join(b.rootDataDir, fmt.Sprintf("%s.db", keyUID)), + filepath.Join(b.rootDataDir, fmt.Sprintf("%s.db-shm", keyUID)), + filepath.Join(b.rootDataDir, fmt.Sprintf("%s.db-wal", keyUID)), } for _, path := range dbFiles { if _, err := os.Stat(path); err == nil { @@ -218,8 +221,20 @@ func (b *GethStatusBackend) ensureAppDBOpened(account multiaccounts.Account, pas if len(b.rootDataDir) == 0 { return errors.New("root datadir wasn't provided") } - path := filepath.Join(b.rootDataDir, fmt.Sprintf("app-%x.sql", account.KeyUID)) - b.appDB, err = appdatabase.InitializeDB(path, password) + + // Migrate file path to fix issue https://github.com/status-im/status-go/issues/2027 + oldPath := filepath.Join(b.rootDataDir, fmt.Sprintf("app-%x.sql", account.KeyUID)) + newPath := filepath.Join(b.rootDataDir, fmt.Sprintf("%s.db", account.KeyUID)) + + _, err = os.Stat(oldPath) + if err == nil { + err := os.Rename(oldPath, newPath) + if err != nil { + return err + } + } + + b.appDB, err = appdatabase.InitializeDB(newPath, password) if err != nil { return err }