mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-22 17:31:03 +01:00
新增几个方法
This commit is contained in:
@@ -26,6 +26,15 @@ type File struct {
|
||||
Size int64 `json:"size"`
|
||||
}
|
||||
|
||||
func (f *GridFs) Remove() {
|
||||
s, gf := database.GetGridFs("files")
|
||||
defer s.Close()
|
||||
if err := gf.RemoveId(f.Id); err != nil {
|
||||
log.Errorf("remove file id error: %s, id: %s", err.Error(), f.Id.Hex())
|
||||
debug.PrintStack()
|
||||
}
|
||||
}
|
||||
|
||||
func GetAllGridFs() []*GridFs {
|
||||
s, gf := database.GetGridFs("files")
|
||||
defer s.Close()
|
||||
|
||||
@@ -124,8 +124,17 @@ func GetSpiderList(filter interface{}, skip int, limit int) ([]Spider, int, erro
|
||||
return spiders, count, nil
|
||||
}
|
||||
|
||||
func GetSpiderByFileId(fileId bson.ObjectId) {
|
||||
func GetSpiderByFileId(fileId bson.ObjectId) *Spider {
|
||||
s, c := database.GetCol("spiders")
|
||||
defer s.Close()
|
||||
|
||||
var result *Spider
|
||||
if err := c.Find(bson.M{"file_id": fileId}).One(&result); err != nil {
|
||||
log.Errorf("get spider error: %s, file_id: %s", err.Error(), fileId.Hex())
|
||||
debug.PrintStack()
|
||||
return nil
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func GetSpiderByName(name string) *Spider {
|
||||
|
||||
Reference in New Issue
Block a user