Skip to content

Commit 628260c

Browse files
committed
Handle errors from chown and chmod.
1 parent 061fbac commit 628260c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

template.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,12 @@ func generateFile(config Config, containers Context) bool {
109109

110110
contents := []byte{}
111111
if fi, err := os.Stat(config.Dest); err == nil {
112-
dest.Chmod(fi.Mode())
113-
dest.Chown(int(fi.Sys().(*syscall.Stat_t).Uid), int(fi.Sys().(*syscall.Stat_t).Gid))
112+
if err := dest.Chmod(fi.Mode()); err != nil {
113+
log.Printf("unable to chmod temp file: %s\n", err)
114+
}
115+
if err := dest.Chown(int(fi.Sys().(*syscall.Stat_t).Uid), int(fi.Sys().(*syscall.Stat_t).Gid)); err != nil {
116+
log.Printf("unable to chown temp file: %s\n", err)
117+
}
114118
contents, err = ioutil.ReadFile(config.Dest)
115119
if err != nil {
116120
log.Fatalf("unable to compare current file contents: %s: %s\n", config.Dest, err)

0 commit comments

Comments
 (0)