Skip to content

Commit

Permalink
Remove a redundant MkdirAll call
Browse files Browse the repository at this point in the history
  • Loading branch information
edw-defang committed Jun 28, 2024
1 parent 37a5a51 commit 73e5b61
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/pkg/cli/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ func InitFromSamples(ctx context.Context, dir string, names []string) error {
defer tarball.Close()
tarReader := tar.NewReader(tarball)
term.Info("Writing files to disk...")
if err := os.MkdirAll(dir, 0755); err != nil {
return err
}
for {
h, err := tarReader.Next()
if err != nil {
Expand All @@ -77,13 +74,13 @@ func InitFromSamples(ctx context.Context, dir string, names []string) error {
}

for _, name := range names {
// Create a subdirectory for each sample when there is more than one sample requested
// Create the sample directory or subdirectory for each sample when there is more than one sample requested
subdir := ""
if len(names) > 1 {
subdir = name
if err := os.MkdirAll(filepath.Join(dir, subdir), 0755); err != nil {
return err
}
}
if err := os.MkdirAll(filepath.Join(dir, subdir), 0755); err != nil {
return err
}
prefix := fmt.Sprintf("%s-%s/samples/%s/", repo, branch, name)
if base, ok := strings.CutPrefix(h.Name, prefix); ok && len(base) > 0 {
Expand Down

0 comments on commit 73e5b61

Please sign in to comment.