Skip to content

Commit

Permalink
fix: close the file before deleting it
Browse files Browse the repository at this point in the history
  • Loading branch information
fisherzrj committed Sep 13, 2023
1 parent 8f357a2 commit 9bffd02
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions download.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,13 @@ func bindFiles(c *DownloadConfig, partialDir string) error {
return errors.Wrapf(err, "failed to open %q in download location", name)
}

defer subfp.Close()

proxy := bar.NewProxyReader(subfp)
if _, err := io.Copy(f, proxy); err != nil {
return errors.Wrapf(err, "failed to copy %q", name)
}

subfp.Close()

// remove a file in download location for join
if err := os.Remove(name); err != nil {
return errors.Wrapf(err, "failed to remove %q in download location", name)
Expand Down

0 comments on commit 9bffd02

Please sign in to comment.