Files
jbergner fe32431d21
release-tag / release-image (push) Failing after 55s
init
2026-08-01 23:54:45 +02:00

24 lines
573 B
Go

//go:build !windows
package app
import (
"errors"
"os"
"syscall"
)
// preserveOwnership applies the owner and group of the original file to the
// temporary replacement file. Permission failures are ignored because the
// process may be allowed to replace the file without being allowed to chown it.
func preserveOwnership(path string, info os.FileInfo) error {
stat, ok := info.Sys().(*syscall.Stat_t)
if !ok {
return nil
}
if err := os.Chown(path, int(stat.Uid), int(stat.Gid)); err != nil && !errors.Is(err, os.ErrPermission) {
return err
}
return nil
}