fix: missing file closding when printing downloading percent of gf cli file for command gf up (#3483)

This commit is contained in:
guangwu
2024-04-16 19:49:09 +08:00
committed by GitHub
parent bbcf49db98
commit ebe567dab2

View File

@ -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)