From 859fa26478d67da5f501ed0ed53c685be4cccc47 Mon Sep 17 00:00:00 2001 From: adnano Date: Thu, 25 Nov 2021 11:43:56 -0500 Subject: [PATCH] Preserve mode bits for static files Fixes: https://todo.sr.ht/~adnano/kiln/25 --- main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index cc21347..6373568 100644 --- a/main.go +++ b/main.go @@ -114,9 +114,15 @@ func copyAll(srcDir, dstDir string) error { } defer src.Close() + sinfo, err := src.Stat() + if err != nil { + return err + } + mode := sinfo.Mode() + dstPath := filepath.Join(dstDir, strings.TrimPrefix(path, srcDir)) os.MkdirAll(filepath.Dir(dstPath), 0755) - dst, err := os.Create(dstPath) + dst, err := os.OpenFile(dstPath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, mode) if err != nil { return err }