Skip to content

Commit 0dc09da

Browse files
authored
all: replace path.Join with filepath.Join (#29479)
* core/rawdb: replace file.Join with filepath.Join Signed-off-by: xiaochangbai <[email protected]> * internal/build: replace file.Join with filepath.Join Signed-off-by: xiaochangbai <[email protected]> --------- Signed-off-by: xiaochangbai <[email protected]>
1 parent 7aafad2 commit 0dc09da

File tree

6 files changed

+14
-15
lines changed

6 files changed

+14
-15
lines changed

core/blockchain_sethead_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ package core
2222
import (
2323
"fmt"
2424
"math/big"
25-
"path"
25+
"path/filepath"
2626
"strings"
2727
"testing"
2828
"time"
@@ -1966,7 +1966,7 @@ func testSetHeadWithScheme(t *testing.T, tt *rewindTest, snapshots bool, scheme
19661966

19671967
// Create a temporary persistent database
19681968
datadir := t.TempDir()
1969-
ancient := path.Join(datadir, "ancient")
1969+
ancient := filepath.Join(datadir, "ancient")
19701970

19711971
db, err := rawdb.Open(rawdb.OpenOptions{
19721972
Directory: datadir,

core/rawdb/database.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"errors"
2222
"fmt"
2323
"os"
24-
"path"
2524
"path/filepath"
2625
"strings"
2726
"time"
@@ -172,7 +171,7 @@ func resolveChainFreezerDir(ancient string) string {
172171
// sub folder, if not then two possibilities:
173172
// - chain freezer is not initialized
174173
// - chain freezer exists in legacy location (root ancient folder)
175-
freezer := path.Join(ancient, ChainFreezerName)
174+
freezer := filepath.Join(ancient, ChainFreezerName)
176175
if !common.FileExist(freezer) {
177176
if !common.FileExist(ancient) {
178177
// The entire ancient store is not initialized, still use the sub

core/rawdb/freezer_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"math/big"
2424
"math/rand"
2525
"os"
26-
"path"
2726
"path/filepath"
2827
"sync"
2928
"testing"
@@ -398,11 +397,11 @@ func TestRenameWindows(t *testing.T) {
398397
if err != nil {
399398
t.Fatal(err)
400399
}
401-
f2, err := os.Create(path.Join(dir1, fname2))
400+
f2, err := os.Create(filepath.Join(dir1, fname2))
402401
if err != nil {
403402
t.Fatal(err)
404403
}
405-
f3, err := os.Create(path.Join(dir2, fname2))
404+
f3, err := os.Create(filepath.Join(dir2, fname2))
406405
if err != nil {
407406
t.Fatal(err)
408407
}
@@ -424,15 +423,15 @@ func TestRenameWindows(t *testing.T) {
424423
if err := f3.Close(); err != nil {
425424
t.Fatal(err)
426425
}
427-
if err := os.Rename(f.Name(), path.Join(dir2, fname)); err != nil {
426+
if err := os.Rename(f.Name(), filepath.Join(dir2, fname)); err != nil {
428427
t.Fatal(err)
429428
}
430-
if err := os.Rename(f2.Name(), path.Join(dir2, fname2)); err != nil {
429+
if err := os.Rename(f2.Name(), filepath.Join(dir2, fname2)); err != nil {
431430
t.Fatal(err)
432431
}
433432

434433
// Check file contents
435-
f, err = os.Open(path.Join(dir2, fname))
434+
f, err = os.Open(filepath.Join(dir2, fname))
436435
if err != nil {
437436
t.Fatal(err)
438437
}
@@ -446,7 +445,7 @@ func TestRenameWindows(t *testing.T) {
446445
t.Errorf("unexpected file contents. Got %v\n", buf)
447446
}
448447

449-
f, err = os.Open(path.Join(dir2, fname2))
448+
f, err = os.Open(filepath.Join(dir2, fname2))
450449
if err != nil {
451450
t.Fatal(err)
452451
}

internal/build/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func UploadSFTP(identityFile, host, dir string, files []string) error {
175175
}
176176
in := io.MultiWriter(stdin, os.Stdout)
177177
for _, f := range files {
178-
fmt.Fprintln(in, "put", f, path.Join(dir, filepath.Base(f)))
178+
fmt.Fprintln(in, "put", f, filepath.Join(dir, filepath.Base(f)))
179179
}
180180
fmt.Fprintln(in, "exit")
181181
// Some issue with the PPA sftp server makes it so the server does not

node/node_auth_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"fmt"
2323
"net/http"
2424
"os"
25-
"path"
25+
"path/filepath"
2626
"testing"
2727
"time"
2828

@@ -98,7 +98,7 @@ func TestAuthEndpoints(t *testing.T) {
9898
t.Fatalf("failed to create jwt secret: %v", err)
9999
}
100100
// Geth must read it from a file, and does not support in-memory JWT secrets, so we create a temporary file.
101-
jwtPath := path.Join(t.TempDir(), "jwt_secret")
101+
jwtPath := filepath.Join(t.TempDir(), "jwt_secret")
102102
if err := os.WriteFile(jwtPath, []byte(hexutil.Encode(secret[:])), 0600); err != nil {
103103
t.Fatalf("failed to prepare jwt secret file: %v", err)
104104
}

signer/core/signed_data_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"math/big"
2525
"os"
2626
"path"
27+
"path/filepath"
2728
"strings"
2829
"testing"
2930

@@ -411,7 +412,7 @@ func TestJsonFiles(t *testing.T) {
411412
// crashes or hangs.
412413
func TestFuzzerFiles(t *testing.T) {
413414
t.Parallel()
414-
corpusdir := path.Join("testdata", "fuzzing")
415+
corpusdir := filepath.Join("testdata", "fuzzing")
415416
testfiles, err := os.ReadDir(corpusdir)
416417
if err != nil {
417418
t.Fatalf("failed reading files: %v", err)

0 commit comments

Comments
 (0)