Skip to content

Commit

Permalink
fix: missing file closding when printing downloading percent of gf cl…
Browse files Browse the repository at this point in the history
…i file for command `gf up` (gogf#3483)
  • Loading branch information
testwill authored Apr 16, 2024
1 parent bbcf49d commit ebe567d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmd/gf/internal/utility/utils/utils_http_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,18 @@ func doPrintDownloadPercent(doneCh chan int64, localSaveFilePath string, total i
stop = false
lastPercentFmt string
)
file, err := os.Open(localSaveFilePath)
if err != nil {
mlog.Fatal(err)
}
defer file.Close()

for {
select {
case <-doneCh:
stop = true

default:
file, err := os.Open(localSaveFilePath)
if err != nil {
mlog.Fatal(err)
}
fi, err := file.Stat()
if err != nil {
mlog.Fatal(err)
Expand Down

0 comments on commit ebe567d

Please sign in to comment.