Try to chown after copy

This commit is contained in:
Ettore Di Giacinto 2021-03-06 18:21:21 +01:00
parent f07cf6c245
commit c13a2174c4

View File

@ -16,6 +16,7 @@
package helpers package helpers
import ( import (
"fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"os" "os"
@ -172,9 +173,18 @@ func CopyFile(src, dst string) (err error) {
return nil return nil
} }
return copy.Copy(src, dst, copy.Options{ err = copy.Copy(src, dst, copy.Options{
Sync: true, Sync: true,
OnSymlink: func(string) copy.SymlinkAction { return copy.Shallow }}) OnSymlink: func(string) copy.SymlinkAction { return copy.Shallow }})
if err != nil {
return err
}
if stat, ok := fi.Sys().(*syscall.Stat_t); ok {
if err := os.Chown(dst, int(stat.Uid), int(stat.Gid)); err != nil {
fmt.Println("failed chowning", dst, err.Error())
}
}
return err
} }
func IsDirectory(path string) (bool, error) { func IsDirectory(path string) (bool, error) {