From b278ea634d51ea7655ff9c37e1de92116914d9e9 Mon Sep 17 00:00:00 2001 From: zhoujunhao <18853925545@163.com> Date: Mon, 15 Oct 2018 17:37:40 +0800 Subject: [PATCH] [ADD] add debug print --- util/comman.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/util/comman.go b/util/comman.go index f94eb2ba7..36234e187 100644 --- a/util/comman.go +++ b/util/comman.go @@ -570,28 +570,37 @@ func Unzip(archive, target string) error { func CopyFile(source, target string) error { sfi, err := os.Stat(source) if err != nil { + fmt.Println("===err1", err) return err } elem := reflect.ValueOf(sfi.Sys()).Elem() uid := elem.FieldByName("Uid").Uint() gid := elem.FieldByName("Gid").Uint() + fmt.Println("file %s uid %d gid %s", source, uid, gid) + sf, err := directio.OpenFile(source, os.O_RDONLY, 0) if err != nil { + fmt.Println("===err2", err) return err } defer sf.Close() tf, err := directio.OpenFile(target, os.O_RDONLY|os.O_CREATE|os.O_WRONLY, sfi.Mode()) if err != nil { + fmt.Println("===err3", err) return err } defer tf.Close() _, err = io.Copy(tf, sf) if err != nil { + fmt.Println("===err4", err) return err } + if err := os.Chown(target, int(uid), int(gid)); err != nil { + fmt.Println("===err5", err) return err } + return nil }