mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-30 18:00:56 +01:00
fix 删除爬虫的问题
This commit is contained in:
24
backend/services/msg_handler/msg_spider.go
Normal file
24
backend/services/msg_handler/msg_spider.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package msg_handler
|
||||
|
||||
import (
|
||||
"crawlab/model"
|
||||
"crawlab/utils"
|
||||
"github.com/globalsign/mgo/bson"
|
||||
"github.com/spf13/viper"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
type Spider struct {
|
||||
SpiderId string
|
||||
}
|
||||
|
||||
func (s *Spider) Handle() error {
|
||||
// 移除本地的爬虫目录
|
||||
spider, err := model.GetSpider(bson.ObjectIdHex(s.SpiderId))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
path := filepath.Join(viper.GetString("spider.path"), spider.Name)
|
||||
utils.RemoveFiles(path)
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user