Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
Don't nuke the download directory (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathias Lindholm authored Jan 25, 2023
1 parent 8a2c8ae commit d0bd250
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
19 changes: 0 additions & 19 deletions cmd/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,6 @@ func downloadCurrentConfiguration(ctx context.Context, d *os.File, absPath strin
log.Fatalf("Error connecting to API: %s", err)
}

names, err := d.Readdirnames(-1)
if err != nil {
log.Fatalf("Reading output directory failed: %s", err)
}
for _, name := range names {
err = os.RemoveAll(filepath.Join(absPath, name))
if err != nil {
log.Fatalf("Deleting output directory contents failed: %s", err)
}
}
err = d.Close()
if err != nil {
log.Fatalf("Reading output directory failed: %s", err)
}

if err := os.MkdirAll(absPath, 0755); err != nil {
log.Fatalf("Could not create the download directory %s: %s", absPath, err)
}

var buf []byte
stream, err := client.DownloadCurrentTrainingData(ctx, &configv1.DownloadCurrentTrainingDataRequest{AppId: appId})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/upload/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func ExtractTarToDir(outDir string, r io.Reader) error {
}
case tar.TypeReg:
fmt.Printf("Writing file %s (%d bytes)\n", target, header.Size)
f, err := os.OpenFile(target, os.O_CREATE|os.O_RDWR, os.FileMode(header.Mode))
f, err := os.OpenFile(target, os.O_RDWR|os.O_CREATE|os.O_TRUNC, os.FileMode(header.Mode))
if err != nil {
return err
}
Expand Down

0 comments on commit d0bd250

Please sign in to comment.