diff --git a/backend/routes/spider.go b/backend/routes/spider.go index 53990308..f4892dd2 100644 --- a/backend/routes/spider.go +++ b/backend/routes/spider.go @@ -441,12 +441,12 @@ func UploadSpider(c *gin.Context) { } } - // 发起同步 - services.PublishAllSpiders() - // 获取爬虫 spider = model.GetSpiderByName(spiderName) + // 发起同步 + services.PublishSpider(spider) + c.JSON(http.StatusOK, Response{ Status: "ok", Message: "success", diff --git a/backend/utils/file.go b/backend/utils/file.go index 072930cf..040b78de 100644 --- a/backend/utils/file.go +++ b/backend/utils/file.go @@ -149,10 +149,9 @@ func DeCompress(srcFile *os.File, dstPath string) error { } // 如果文件目录不存在,则创建一个 - dirPath := filepath.Dir(innerFile.Name) + dirPath := filepath.Join(dstPath, filepath.Dir(innerFile.Name)) if !Exists(dirPath) { - err = os.MkdirAll(filepath.Join(dstPath, dirPath), os.ModeDir|os.ModePerm) - if err != nil { + if err = os.MkdirAll(dirPath, os.ModeDir|os.ModePerm); err != nil { log.Errorf("Unzip File Error : " + err.Error()) debug.PrintStack() return err @@ -168,7 +167,8 @@ func DeCompress(srcFile *os.File, dstPath string) error { } // 创建新文件 - newFile, err := os.OpenFile(filepath.Join(dstPath, innerFile.Name), os.O_RDWR|os.O_CREATE|os.O_TRUNC, info.Mode()) + newFilePath := filepath.Join(dstPath, innerFile.Name) + newFile, err := os.OpenFile(newFilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, info.Mode()) if err != nil { log.Errorf("Unzip File Error : " + err.Error()) debug.PrintStack()