fix chmod for read only files

pull/16408/head
Steven Powell 2023-05-02 11:47:30 -07:00
parent 66ea3c6634
commit 0705e6bc25
2 changed files with 5 additions and 5 deletions

View File

@ -209,5 +209,10 @@ func writeFile(dst string, f assets.CopyableFile, perms os.FileMode) error {
if n != int64(f.GetLength()) {
return fmt.Errorf("%s: expected to write %d bytes, but wrote %d instead", dst, f.GetLength(), n)
}
if err := w.Chmod(os.FileMode(perms)); err != nil {
return errors.Wrap(err, "chmod")
}
return w.Close()
}

View File

@ -166,11 +166,6 @@ func (e *execRunner) Copy(f assets.CopyableFile) error {
}
defer os.Remove(tmpfile.Name())
// ... set the file permission ...
if err := tmpfile.Chmod(os.FileMode(perms)); err != nil {
return errors.Wrap(err, "error setting file permissions")
}
if err := writeFile(tmpfile.Name(), f, os.FileMode(perms)); err != nil {
return errors.Wrapf(err, "error writing to tempfile %s", tmpfile.Name())
}