Skip to content

Commit 34a245f

Browse files
authored
all: use common.FileExist for checking file existence ethereum#24748 (#1212)
1 parent f272ce1 commit 34a245f

File tree

5 files changed

+6
-5
lines changed

5 files changed

+6
-5
lines changed

build/ci.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import (
4949
"runtime"
5050
"strings"
5151

52+
"github.com/XinFinOrg/XDPoSChain/common"
5253
"github.com/XinFinOrg/XDPoSChain/internal/build"
5354
)
5455

@@ -79,7 +80,7 @@ func executablePath(name string) string {
7980
func main() {
8081
log.SetFlags(log.Lshortfile)
8182

82-
if _, err := os.Stat(filepath.Join("build", "ci.go")); os.IsNotExist(err) {
83+
if !common.FileExist(filepath.Join("build", "ci.go")) {
8384
log.Fatal("this script must be run from the root of the repository")
8485
}
8586
if len(os.Args) < 2 {

cmd/utils/flags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
15841584
}
15851585
if ctx.IsSet(StoreRewardFlag.Name) {
15861586
common.StoreRewardFolder = filepath.Join(stack.DataDir(), "XDC", "rewards")
1587-
if _, err := os.Stat(common.StoreRewardFolder); os.IsNotExist(err) {
1587+
if !common.FileExist(common.StoreRewardFolder) {
15881588
os.Mkdir(common.StoreRewardFolder, os.ModePerm)
15891589
}
15901590
}

core/txpool/journal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func newTxJournal(path string) *journal {
5858
// the specified pool.
5959
func (journal *journal) load(add func([]*types.Transaction) []error) error {
6060
// Skip the parsing if the journal file doens't exist at all
61-
if _, err := os.Stat(journal.path); os.IsNotExist(err) {
61+
if !common.FileExist(journal.path) {
6262
return nil
6363
}
6464
// Open the journal for loading any past transactions

core/txpool/lending_tx_journal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func newLendingTxJournal(path string) *lendingtxJournal {
4444
// the specified pool.
4545
func (journal *lendingtxJournal) load(add func(*types.LendingTransaction) error) error {
4646
// Skip the parsing if the journal file doens't exist at all
47-
if _, err := os.Stat(journal.path); os.IsNotExist(err) {
47+
if !common.FileExist(journal.path) {
4848
return nil
4949
}
5050
// Open the journal for loading any past transactions

core/txpool/order_tx_journal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func newOrderTxJournal(path string) *ordertxJournal {
4444
// the specified pool.
4545
func (journal *ordertxJournal) load(add func(*types.OrderTransaction) error) error {
4646
// Skip the parsing if the journal file doens't exist at all
47-
if _, err := os.Stat(journal.path); os.IsNotExist(err) {
47+
if !common.FileExist(journal.path) {
4848
return nil
4949
}
5050
// Open the journal for loading any past transactions

0 commit comments

Comments
 (0)