build source

This commit is contained in:
build 2026-04-16 04:16:36 +00:00
commit ee1fec43ed
4171 changed files with 1351288 additions and 0 deletions

View 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
}