Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions core/tx_journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ func newTxJournal(path string) *txJournal {
// load parses a transaction journal dump from disk, loading its contents into
// the specified pool.
func (journal *txJournal) load(add func([]*types.Transaction) []error) error {
// Skip the parsing if the journal file doesn't exist at all
if !common.FileExist(journal.path) {
return nil
}
// Open the journal for loading any past transactions
input, err := os.Open(journal.path)
if os.IsNotExist(err) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks good, but the method doc says it's deprecated and has a suggestion for how to do it in new code:

This function predates errors.Is. It only supports errors returned by the os package. New code should use errors.Is(err, fs.ErrNotExist).

https://pkg.go.dev/os#IsNotExist

Copy link
Contributor Author

@dbadoy dbadoy Aug 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the cause of deprecated, I think it could be use the os.ErrNotExist without import fs.
(golang/go#38198)

in os package
ErrNotExist = fs.ErrNotExist (https://pkg.go.dev/os#pkg-variables)

Using fs.ErrNotExist with fs import or using os.ErrNotExist, which one better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have applied that !

// Skip the parsing if the journal file doesn't exist at all
return nil
}
if err != nil {
return err
}
Expand Down