Skip to content

Commit

Permalink
internal/robustio: reimport from upstream
Browse files Browse the repository at this point in the history
This imports robustio from the Go project at commit dc04f3ba1f25313bc9c97e728620206c235db9ee.

This replaces the remaining references to ioutil.
  • Loading branch information
dominikh committed Jan 26, 2023
1 parent 7b85197 commit d035bf8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion internal/robustio/UPSTREAM
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ It is mostly in sync with upstream according to the last commit we've looked at,
with the exception of still using I/O functions that work with older Go versions.

The last upstream commit we've looked at was:
06ac303f6a14b133254f757e54599c48e3c2a4ad
dc04f3ba1f25313bc9c97e728620206c235db9ee
2 changes: 1 addition & 1 deletion internal/robustio/robustio.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func Rename(oldpath, newpath string) error {
return rename(oldpath, newpath)
}

// ReadFile is like ioutil.ReadFile, but on Windows retries errors that may
// ReadFile is like os.ReadFile, but on Windows retries errors that may
// occur if the file is concurrently replaced.
//
// (See golang.org/issue/31247 and golang.org/issue/32188.)
Expand Down
6 changes: 2 additions & 4 deletions internal/robustio/robustio_flaky.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
// license that can be found in the LICENSE file.

//go:build windows || darwin
// +build windows darwin

package robustio

import (
"errors"
"io/ioutil"
"math/rand"
"os"
"syscall"
Expand Down Expand Up @@ -71,11 +69,11 @@ func rename(oldpath, newpath string) (err error) {
})
}

// readFile is like ioutil.ReadFile, but retries ephemeral errors.
// readFile is like os.ReadFile, but retries ephemeral errors.
func readFile(filename string) ([]byte, error) {
var b []byte
err := retry(func() (err error, mayRetry bool) {
b, err = ioutil.ReadFile(filename)
b, err = os.ReadFile(filename)

// Unlike in rename, we do not retry errFileNotFound here: it can occur
// as a spurious error, but the file may also genuinely not exist, so the
Expand Down
1 change: 0 additions & 1 deletion internal/robustio/robustio_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build !windows && !darwin
// +build !windows,!darwin

package robustio

Expand Down

0 comments on commit d035bf8

Please sign in to comment.