We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
版本:0.4.7(最新的master也会存在这个问题) 文件路径: crawlab/backend/routes/spider.go 函数名称:UploadSpider 代码开始行数: 265 代码片段: if spider.Name == "" { // 保存爬虫信息 srcPath := viper.GetString("spider.path") spider := model.Spider{ Name: spiderName, DisplayName: spiderName, Type: constants.Customized, Src: filepath.Join(srcPath, spiderName), FileId: fid, } if name != "" { spider.Name = name } if displayName != "" { spider.DisplayName = displayName } if col != "" { spider.Col = col } if cmd != "" { spider.Cmd = cmd } if err := spider.Add(); err != nil { log.Error("add spider error: " + err.Error()) debug.PrintStack() HandleError(http.StatusInternalServerError, c, err) return } } else { if name != "" { spider.Name = name } if displayName != "" { spider.DisplayName = displayName } if col != "" { spider.Col = col } if cmd != "" { spider.Cmd = cmd } // 更新file_id spider.FileId = fid if err := spider.Add(); err != nil { log.Error("add spider error: " + err.Error()) debug.PrintStack() HandleError(http.StatusInternalServerError, c, err) return } }
if spider.Name == "" { // 保存爬虫信息 srcPath := viper.GetString("spider.path") spider := model.Spider{ Name: spiderName, DisplayName: spiderName, Type: constants.Customized, Src: filepath.Join(srcPath, spiderName), FileId: fid, } if name != "" { spider.Name = name } if displayName != "" { spider.DisplayName = displayName } if col != "" { spider.Col = col } if cmd != "" { spider.Cmd = cmd } if err := spider.Add(); err != nil { log.Error("add spider error: " + err.Error()) debug.PrintStack() HandleError(http.StatusInternalServerError, c, err) return } } else { if name != "" { spider.Name = name } if displayName != "" { spider.DisplayName = displayName } if col != "" { spider.Col = col } if cmd != "" { spider.Cmd = cmd } // 更新file_id spider.FileId = fid if err := spider.Add(); err != nil { log.Error("add spider error: " + err.Error()) debug.PrintStack() HandleError(http.StatusInternalServerError, c, err) return } }
在该代码中找不到spider name是增加爬虫没错,但是找到了也是增加爬虫,这逻辑是不是有问题, 是不是应该将else里面到spider.Add()改成spider.Save()
这个问题会导致在新版本中上传两次相同的爬虫名会增加同样的爬虫而不是更新
The text was updated successfully, but these errors were encountered:
把代码地址发一下
Sorry, something went wrong.
什么代码地址,就是crawlab的master分支上的代码啊
不好意思,没看到前面的描述。
这里确实可能出现问题。我们讨论一下看看。同时,您也可以提一个PR到develop分支
fixed in develop
No branches or pull requests
版本:0.4.7(最新的master也会存在这个问题)
文件路径: crawlab/backend/routes/spider.go
函数名称:UploadSpider
代码开始行数: 265
代码片段:
if spider.Name == "" { // 保存爬虫信息 srcPath := viper.GetString("spider.path") spider := model.Spider{ Name: spiderName, DisplayName: spiderName, Type: constants.Customized, Src: filepath.Join(srcPath, spiderName), FileId: fid, } if name != "" { spider.Name = name } if displayName != "" { spider.DisplayName = displayName } if col != "" { spider.Col = col } if cmd != "" { spider.Cmd = cmd } if err := spider.Add(); err != nil { log.Error("add spider error: " + err.Error()) debug.PrintStack() HandleError(http.StatusInternalServerError, c, err) return } } else { if name != "" { spider.Name = name } if displayName != "" { spider.DisplayName = displayName } if col != "" { spider.Col = col } if cmd != "" { spider.Cmd = cmd } // 更新file_id spider.FileId = fid if err := spider.Add(); err != nil { log.Error("add spider error: " + err.Error()) debug.PrintStack() HandleError(http.StatusInternalServerError, c, err) return } }
在该代码中找不到spider name是增加爬虫没错,但是找到了也是增加爬虫,这逻辑是不是有问题, 是不是应该将else里面到spider.Add()改成spider.Save()
这个问题会导致在新版本中上传两次相同的爬虫名会增加同样的爬虫而不是更新
The text was updated successfully, but these errors were encountered: