Files
crawlab/core/controllers/sync.go
Marvin Zhang 4dace3ce8e refactor: migrate router and controller methods to use Fizz package
- Updated router groups to utilize the new crawlab-team/fizz package for improved routing capabilities.
- Refactored controller methods to accept Fizz router groups, enhancing consistency and maintainability.
- Simplified route registration by incorporating OpenAPI metadata directly into group definitions.
- Improved error handling and response generation in sync controller methods for better clarity.
- Enhanced overall code structure by standardizing route definitions and improving parameter handling.
2025-03-17 12:50:50 +08:00

26 lines
594 B
Go

package controllers
import (
"path/filepath"
"github.com/crawlab-team/crawlab/core/utils"
"github.com/gin-gonic/gin"
)
func GetSyncScan(c *gin.Context) {
workspacePath := utils.GetWorkspace()
dirPath := filepath.Join(workspacePath, c.Param("id"), c.Param("path"))
files, err := utils.ScanDirectory(dirPath)
if err != nil {
HandleErrorInternalServerError(c, err)
return
}
HandleSuccessWithData(c, files)
}
func GetSyncDownload(c *gin.Context) {
workspacePath := utils.GetWorkspace()
filePath := filepath.Join(workspacePath, c.Param("id"), c.Param("path"))
c.File(filePath)
}