lang: Improve the gapi copying

We hit a weird bug where dirs would not get copied properly. I thought
the solution might be to add the missing dirs so they'd get a proper
mkdir, but in the end that didn't work well, so we just use `mkdirall`
and that seems to work. Let's leave it like this for now. Some of the
previous work for that is in the previous commit.
This commit is contained in:
James Shubin
2019-07-26 03:33:27 -04:00
parent 4bf9b4d41b
commit 10804c4b25

View File

@@ -330,6 +330,27 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {
return nil, fmt.Errorf("duplicates in file list found")
}
// Add any missing dirs, so that we don't need to use `MkdirAll`...
// FIXME: It's possible that the dirs get generated upstream, but it's
// not exactly clear where they'd need to get added into the list. If we
// figure that out, we can remove this additional step. It's trickier,
// because adding duplicates isn't desirable either.
//dirs, err := util.MissingMkdirs(files)
//if err != nil {
// // possible programming error
// return nil, errwrap.Wrapf(err, "unexpected missing mkdirs input")
//}
//parents := util.DirParents(output.Base)
//parents = append(parents, output.Base) // include self
//
// And we don't want to include any of the parents above the Base dir...
//for _, x := range dirs {
// if util.StrInList(x, parents) {
// continue
// }
// files = append(files, x)
//}
// sort by depth dependency order! (or mkdir -p all the dirs first)
// TODO: is this natively already in a correctly sorted order?
util.PathSlice(files).Sort() // sort it
@@ -352,7 +373,8 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {
dst = out
}
// TODO: add more tests to this (it is actually CopyFs)
if err := gapi.CopyDirToFs(fs, src, dst); err != nil {
// TODO: Used to be: CopyDirToFs, but it had issues...
if err := gapi.CopyDirToFsForceAll(fs, src, dst); err != nil {
return nil, errwrap.Wrapf(err, "can't copy dir from `%s` to `%s`", src, dst)
}
continue