gapi, lang: gapi: Make dir to avoid errors
It seems we sometimes need to make the intermediate dir.
This commit is contained in:
@@ -89,3 +89,9 @@ func CopyDirToFsForceAll(fs engine.Fs, src, dst string) error {
|
||||
func CopyDirContentsToFs(fs engine.Fs, src, dst string) error {
|
||||
return util.CopyDiskContentsToFs(fs, src, dst, false)
|
||||
}
|
||||
|
||||
// MkdirAllOnFs writes a dir to a dst path on fs. It makes the parent dirs if
|
||||
// they don't exist.
|
||||
func MkdirAllOnFs(fs engine.WriteableFS, dst string, perm os.FileMode) error {
|
||||
return fs.MkdirAll(dst, perm)
|
||||
}
|
||||
|
||||
@@ -463,6 +463,11 @@ func (obj *GAPI) Cli(info *gapi.Info) (*gapi.Deploy, error) {
|
||||
continue
|
||||
}
|
||||
// it's a regular file path
|
||||
|
||||
// Occasionally, we need the dir to exist first or we'll error.
|
||||
if err := gapi.MkdirAllOnFs(writeableFS, util.Dirname(dst), 0700); err != nil {
|
||||
return nil, errwrap.Wrapf(err, "can't mkdir at `%s`", dst)
|
||||
}
|
||||
if err := gapi.CopyFileToFs(writeableFS, src, dst); err != nil {
|
||||
return nil, errwrap.Wrapf(err, "can't copy file from `%s` to `%s`", src, dst)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user