all: use common.FileExist for checking file existence #24748 (#1212)

This commit is contained in:
Daniel Liu 2025-07-11 10:42:51 +08:00 committed by GitHub
parent f272ce1123
commit 34a245fbc8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 6 additions and 5 deletions

View file

@ -49,6 +49,7 @@ import (
"runtime"
"strings"
"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/internal/build"
)
@ -79,7 +80,7 @@ func executablePath(name string) string {
func main() {
log.SetFlags(log.Lshortfile)
if _, err := os.Stat(filepath.Join("build", "ci.go")); os.IsNotExist(err) {
if !common.FileExist(filepath.Join("build", "ci.go")) {
log.Fatal("this script must be run from the root of the repository")
}
if len(os.Args) < 2 {

View file

@ -1584,7 +1584,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
}
if ctx.IsSet(StoreRewardFlag.Name) {
common.StoreRewardFolder = filepath.Join(stack.DataDir(), "XDC", "rewards")
if _, err := os.Stat(common.StoreRewardFolder); os.IsNotExist(err) {
if !common.FileExist(common.StoreRewardFolder) {
os.Mkdir(common.StoreRewardFolder, os.ModePerm)
}
}

View file

@ -58,7 +58,7 @@ func newTxJournal(path string) *journal {
// the specified pool.
func (journal *journal) load(add func([]*types.Transaction) []error) error {
// Skip the parsing if the journal file doens't exist at all
if _, err := os.Stat(journal.path); os.IsNotExist(err) {
if !common.FileExist(journal.path) {
return nil
}
// Open the journal for loading any past transactions

View file

@ -44,7 +44,7 @@ func newLendingTxJournal(path string) *lendingtxJournal {
// the specified pool.
func (journal *lendingtxJournal) load(add func(*types.LendingTransaction) error) error {
// Skip the parsing if the journal file doens't exist at all
if _, err := os.Stat(journal.path); os.IsNotExist(err) {
if !common.FileExist(journal.path) {
return nil
}
// Open the journal for loading any past transactions

View file

@ -44,7 +44,7 @@ func newOrderTxJournal(path string) *ordertxJournal {
// the specified pool.
func (journal *ordertxJournal) load(add func(*types.OrderTransaction) error) error {
// Skip the parsing if the journal file doens't exist at all
if _, err := os.Stat(journal.path); os.IsNotExist(err) {
if !common.FileExist(journal.path) {
return nil
}
// Open the journal for loading any past transactions