Skip to content

Commit

Permalink
fix: cleanup after extracting repo tarball
Browse files Browse the repository at this point in the history
  • Loading branch information
leg100 committed Aug 7, 2023
1 parent 478e314 commit bf4758b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/github/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,12 @@ func (g *Client) GetRepoTarball(ctx context.Context, opts cloud.GetRepoTarballOp
// <owner>-<repo>-<commit>. We need a tarball without this parent directory,
// so we untar it to a temp dir, then tar it up the contents of the parent
// directory.
//
// TODO: remove temp dir after finishing
untarpath, err := os.MkdirTemp("", fmt.Sprintf("github-%s-%s-*", owner, name))
if err != nil {
return nil, "", err
}
defer os.RemoveAll(untarpath)

if err := internal.Unpack(resp.Body, untarpath); err != nil {
return nil, "", err
}
Expand Down
2 changes: 2 additions & 0 deletions internal/gitlab/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ func (g *Client) GetRepoTarball(ctx context.Context, opts cloud.GetRepoTarballOp
if err != nil {
return nil, "", err
}
defer os.RemoveAll(untarpath)

if err := internal.Unpack(bytes.NewReader(tarball), untarpath); err != nil {
return nil, "", err
}
Expand Down

0 comments on commit bf4758b

Please sign in to comment.