fix 无法删除爬虫的问题

This commit is contained in:
陈景阳
2019-09-30 09:23:42 +08:00
parent bbc5401e31
commit d93bff63e7
2 changed files with 8 additions and 4 deletions

View File

@@ -126,7 +126,7 @@ func (s *Scheduler) Update() error {
// 添加到定时任务
if err := s.AddJob(job); err != nil {
log.Errorf("add job error: %s", err.Error())
log.Errorf("add job error: %s, job: %s, cron: %s", err.Error(), job.Name, job.Cron)
debug.PrintStack()
return err
}

View File

@@ -45,11 +45,15 @@ func (s *SpiderSync) GetLockDownloadKey(spiderId string) string {
// 删除本地文件
func (s *SpiderSync) RemoveSpiderFile() {
//爬虫文件有变化,先删除本地文件
_ = os.Remove(filepath.Join(
path := filepath.Join(
viper.GetString("spider.path"),
s.Spider.Name,
))
)
//爬虫文件有变化,先删除本地文件
if err := os.RemoveAll(path); err != nil {
log.Errorf("remove spider files error: %s, path: %s", err.Error(), path)
debug.PrintStack()
}
}
// 检测是否已经下载中