Skip to content

Commit 67bf890

Browse files
committed
fix(agent): support Windows zip package download
- Fix Download function to use .zip extension for Windows packages - Linux/macOS use .tar.gz, Windows use .zip - Add run-with-packages command for local development with agent support
1 parent 8023d4f commit 67bf890

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

internal/routers/agent/agent.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,17 +376,25 @@ func Download(c *gin.Context) {
376376
return
377377
}
378378

379+
// 根据操作系统选择文件扩展名
380+
ext := ".tar.gz"
381+
filename := fmt.Sprintf("gocron-node-%s-%s.tar.gz", os, arch)
382+
if os == "windows" {
383+
ext = ".zip"
384+
filename = fmt.Sprintf("gocron-node-%s-%s.zip", os, arch)
385+
}
386+
379387
// 查找匹配的包文件
380-
packagePattern := fmt.Sprintf("./gocron-node-package/gocron-node-*-%s-%s.tar.gz", os, arch)
388+
packagePattern := fmt.Sprintf("./gocron-node-package/gocron-node-*-%s-%s%s", os, arch, ext)
381389
matches, err := filepath.Glob(packagePattern)
382390
if err != nil || len(matches) == 0 {
383391
// 开发环境提示
384-
logger.Warnf("Package not found for %s-%s, run 'make package' to build all platforms", os, arch)
392+
logger.Warnf("Package not found for %s-%s, run 'make package-all' to build all platforms", os, arch)
385393
c.String(http.StatusNotFound, fmt.Sprintf("Package not found for %s-%s. Please run 'make package-all' to build packages for all platforms.", os, arch))
386394
return
387395
}
388396

389-
c.FileAttachment(matches[0], fmt.Sprintf("gocron-node-%s-%s.tar.gz", os, arch))
397+
c.FileAttachment(matches[0], filename)
390398
}
391399

392400
func generateRandomToken() string {

0 commit comments

Comments
 (0)