Skip to content

Commit

Permalink
fix log file overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
bufsnake committed Apr 22, 2021
1 parent 9047772 commit b605d07
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
. "github.com/logrusorgru/aurora"
"io/ioutil"
url2 "net/url"
"os"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -241,10 +242,18 @@ func (c *core) httpdownload(wait *sync.WaitGroup, httpd chan string) {
if err != nil {
log.Info("file download error", err)
// 将URL保存到文件
err := ioutil.WriteFile(config.LogFileName, []byte(url+"\n"), 644)
file, err := os.OpenFile(config.LogFileName, os.O_WRONLY|os.O_APPEND, 0644)
if err != nil {
log.Warn(err)
continue
}
_, err = file.WriteString(url + "\n")
if err != nil {
file.Close()
log.Warn(err)
continue
}
file.Close()
}
}
}

0 comments on commit b605d07

Please sign in to comment.