Update usage of os.IsNotExist (#29)
Per [godoc](https://pkg.go.dev/os#IsNotExist), this is the preferred method.
This commit is contained in:
@@ -54,9 +54,9 @@ func (s *fileStore) GetMeta() (map[string]json.RawMessage, error) {
|
||||
|
||||
func (s *fileStore) readData() error {
|
||||
stat, err := os.Stat(s.filename)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
return errors.Wrap(err, "stat file store")
|
||||
} else if os.IsNotExist(err) {
|
||||
} else if errors.Is(err, os.ErrNotExist) {
|
||||
// initialize empty
|
||||
s.metadata = metadataMap{}
|
||||
return nil
|
||||
|
||||
@@ -235,7 +235,7 @@ func (u *Updater) Download(repoPath, localPath string) error {
|
||||
|
||||
if constant.PlatformName == "windows" {
|
||||
// Remove old file first
|
||||
if err := os.Rename(localPath, localPath+".old"); err != nil && !os.IsNotExist(err) {
|
||||
if err := os.Rename(localPath, localPath+".old"); err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
return errors.Wrap(err, "rename old")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user