Skip to content

Commit

Permalink
Merge pull request #242 from wo10378931/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
wo10378931 authored Oct 7, 2019
2 parents b9f316c + 4a40d38 commit 9a973ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion backend/routes/spider.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func PutSpider(c *gin.Context) {
// 以防tmp目录不存在
tmpPath := viper.GetString("other.tmppath")
if !utils.Exists(tmpPath) {
if err := os.Mkdir(tmpPath, os.ModePerm); err != nil {
if err := os.MkdirAll(tmpPath, os.ModePerm); err != nil {
log.Error("mkdir other.tmppath dir error:" + err.Error())
debug.PrintStack()
HandleError(http.StatusBadRequest, c, errors.New("Mkdir other.tmppath dir error"))
Expand Down
5 changes: 5 additions & 0 deletions backend/services/spider.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"os"
"path/filepath"
"runtime/debug"
"strings"
)

type SpiderFileData struct {
Expand Down Expand Up @@ -144,7 +145,11 @@ func PublishSpider(spider model.Spider) {
}
// md5值不一样,则下载
md5Str := utils.ReadFileOneLine(md5)
// 去掉空格以及换行符
md5Str = strings.Replace(md5Str, " ", "", -1)
md5Str = strings.Replace(md5Str, "\n", "", -1)
if gfFile.Md5 != md5Str {
log.Infof("md5 is different, gf-md5:%s, file-md5:%s", gfFile.Md5, md5Str)
spiderSync.RemoveSpiderFile()
spiderSync.Download()
spiderSync.CreateMd5File(gfFile.Md5)
Expand Down

0 comments on commit 9a973ab

Please sign in to comment.