Skip to content

Commit

Permalink
feat(import): copy folder contents
Browse files Browse the repository at this point in the history
  • Loading branch information
rchincha committed Apr 3, 2023
1 parent 479fca8 commit de3c13f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pkg/stacker/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func importFile(imp string, cacheDir string, hash string, idest string, mode *fs
}

if !e1.IsDir() {
log.Infof("not a dir %s", imp)
err := verifyImportFileHash(imp, hash)
if err != nil {
return "", err
Expand Down Expand Up @@ -124,7 +125,13 @@ func importFile(imp string, cacheDir string, hash string, idest string, mode *fs
return dest, nil
}

dest := path.Join(cacheDir, path.Base(imp))
var dest string
if idest != "" {
dest = cacheDir
} else {
dest = path.Join(cacheDir, path.Base(imp))
}

if err := os.MkdirAll(dest, 0755); err != nil {
return "", errors.Wrapf(err, "failed making cache dir")
}
Expand Down Expand Up @@ -156,7 +163,12 @@ func importFile(imp string, cacheDir string, hash string, idest string, mode *fs
fallthrough
case mtree.Extra:
srcpath := path.Join(imp, d.Path())
destpath := path.Join(cacheDir, path.Base(imp), d.Path())
var destpath string
if idest != "" {
destpath = path.Join(cacheDir, d.Path())
} else {
destpath = path.Join(cacheDir, path.Base(imp), d.Path())
}

if d.New().IsDir() {
fi, err := os.Lstat(destpath)
Expand Down

0 comments on commit de3c13f

Please sign in to comment.