build source
This commit is contained in:
commit
ee1fec43ed
4171 changed files with 1351288 additions and 0 deletions
27
vendor/github.com/fergusstrange/embedded-postgres/rename.go
generated
vendored
Normal file
27
vendor/github.com/fergusstrange/embedded-postgres/rename.go
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package embeddedpostgres
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// renameOrIgnore will rename the oldpath to the newpath.
|
||||
//
|
||||
// On Unix this will be a safe atomic operation.
|
||||
// On Windows this will do nothing if the new path already exists.
|
||||
//
|
||||
// This is only safe to use if you can be sure that the newpath is either missing, or contains the same data as the
|
||||
// old path.
|
||||
func renameOrIgnore(oldpath, newpath string) error {
|
||||
err := os.Rename(oldpath, newpath)
|
||||
|
||||
// if the error is due to syscall.EEXIST then this is most likely windows, and a race condition with
|
||||
// multiple downloads of the file. We can assume that the existing file is the correct one and ignore
|
||||
// the error
|
||||
if errors.Is(err, syscall.EEXIST) {
|
||||
return nil
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue