X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=cmd%2Fsafcm-remote%2Fsync%2Ffiletest%2Ffiletest.go;h=370ca10edfa4744aa41318397cf7af56782c51ec;hb=6089e2fbed6bf995122f331ceffcfc8c7b9dda31;hp=b6fcb7c9bd2daef63fac32b8e2e7512215136a5e;hpb=326baeaca101fdee43b22c45a7c304a0fdea027f;p=safcm%2Fsafcm.git diff --git a/cmd/safcm-remote/sync/filetest/filetest.go b/cmd/safcm-remote/sync/filetest/filetest.go index b6fcb7c..370ca10 100644 --- a/cmd/safcm-remote/sync/filetest/filetest.go +++ b/cmd/safcm-remote/sync/filetest/filetest.go @@ -34,7 +34,9 @@ type File struct { func WalkDir(basePath string) ([]File, error) { var res []File - err := filepath.WalkDir(basePath, func(path string, d fs.DirEntry, err error) error { + err := filepath.WalkDir(basePath, func(path string, + d fs.DirEntry, err error) error { + if err != nil { return err } @@ -63,6 +65,7 @@ func WalkDir(basePath string) ([]File, error) { return err } f.Data = []byte(x) + f.Mode |= 0777 // see sync/files.go } res = append(res, f) return nil @@ -94,7 +97,7 @@ func CurrentUserAndGroup() (string, int, string, int) { } func CreateFile(path string, data string, mode fs.FileMode) { - err := os.WriteFile(path, []byte(data), 0644) + err := os.WriteFile(path, []byte(data), 0600) if err != nil { panic(err) } @@ -122,6 +125,17 @@ func CreateDirectory(path string, mode fs.FileMode) { } } +func CreateDirectoryExists(path string, mode fs.FileMode) { + err := os.Mkdir(path, 0700) + if err != nil && !os.IsExist(err) { + panic(err) + } + err = os.Chmod(path, mode) + if err != nil { + panic(err) + } +} + func CreateFifo(path string, mode fs.FileMode) { err := syscall.Mkfifo(path, 0600) if err != nil {