refactor: extract path logic to path.go and run go fmt on codebase
This commit is contained in:
@@ -486,7 +486,7 @@ func (es *ExecutorService) ExecuteDispatcher(ctx context.Context, req *executor.
|
||||
|
||||
// 组合指令逻辑已移至 executor.ExecuteWithHooks 中,此处不再处理
|
||||
// 以避免指令被重复组合。
|
||||
|
||||
|
||||
// 远程任务
|
||||
if task.AgentID != nil && *task.AgentID != "" {
|
||||
// 将请求中已包含的环境变量(已合并)传递给 Agent
|
||||
@@ -806,7 +806,7 @@ func (es *ExecutorService) StopTaskExecution(logID string) error {
|
||||
taskLog.Status = constant.TaskStatusFailed
|
||||
errorMessage := "任务执行实例已丢失(可能由于系统重启导致),已自动同步状态为失败"
|
||||
taskLog.Error = models.BigText(errorMessage)
|
||||
|
||||
|
||||
// 更新数据库状态
|
||||
database.DB.Model(&taskLog).Updates(map[string]interface{}{
|
||||
"status": taskLog.Status,
|
||||
|
||||
@@ -4,11 +4,11 @@ import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/engigu/baihu-panel/internal/constant"
|
||||
"github.com/engigu/baihu-panel/internal/database"
|
||||
"github.com/engigu/baihu-panel/internal/logger"
|
||||
"github.com/engigu/baihu-panel/internal/models"
|
||||
"github.com/engigu/baihu-panel/internal/systime"
|
||||
"github.com/engigu/baihu-panel/internal/constant"
|
||||
"github.com/engigu/baihu-panel/internal/utils"
|
||||
)
|
||||
|
||||
|
||||
@@ -92,7 +92,6 @@ func (ts *TaskService) CreateTask(p *TaskParam) *models.Task {
|
||||
}
|
||||
database.DB.Select("*").Create(task)
|
||||
|
||||
|
||||
return task
|
||||
}
|
||||
|
||||
@@ -111,7 +110,7 @@ func (ts *TaskService) GetTasksWithPagination(page, pageSize int, name string, a
|
||||
if name != "" {
|
||||
query = query.Where("name LIKE ? OR remark LIKE ?", "%"+name+"%", "%"+name+"%")
|
||||
}
|
||||
|
||||
|
||||
// 标签筛选 (并集)
|
||||
if tags != "" {
|
||||
tagList := strings.Split(tags, ",")
|
||||
@@ -200,7 +199,7 @@ func (ts *TaskService) UpdateTask(id string, p *TaskParam) *models.Task {
|
||||
func (ts *TaskService) DeleteTask(id string) bool {
|
||||
// 同时删除关联的通知推送设置
|
||||
database.DB.Where("type = ? AND data_id = ?", constant.BindingTypeTask, id).Delete(&models.NotifyBinding{})
|
||||
|
||||
|
||||
result := database.DB.Where("id = ?", id).Delete(&models.Task{})
|
||||
return result.RowsAffected > 0
|
||||
}
|
||||
@@ -208,7 +207,7 @@ func (ts *TaskService) DeleteTask(id string) bool {
|
||||
func (ts *TaskService) BatchDeleteTasks(ids []string) int64 {
|
||||
// 同时删除关联的通知推送设置
|
||||
database.DB.Where("type = ? AND data_id IN ?", constant.BindingTypeTask, ids).Delete(&models.NotifyBinding{})
|
||||
|
||||
|
||||
result := database.DB.Where("id IN ?", ids).Delete(&models.Task{})
|
||||
return result.RowsAffected
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ type TinyLog struct {
|
||||
path string
|
||||
writer *bufio.Writer
|
||||
subscribers []chan []byte
|
||||
remainder []byte // Leftover bytes from previous write (partial lines)
|
||||
remainder []byte // Leftover bytes from previous write (partial lines)
|
||||
masks []string // Secrets to mask
|
||||
closed bool
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestTinyLog_UTF8Splitting(t *testing.T) {
|
||||
}
|
||||
|
||||
_, _ = tl.Write(part2)
|
||||
// Currently it should collect both parts but still no newline,
|
||||
// Currently it should collect both parts but still no newline,
|
||||
// so remainder should be 5 bytes.
|
||||
if len(tl.remainder) != 5 {
|
||||
t.Errorf("Expected remainder len 5, got %d", len(tl.remainder))
|
||||
@@ -58,7 +58,7 @@ func TestTinyLog_CarriageReturn(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("ReadLastLines failed: %v", err)
|
||||
}
|
||||
|
||||
|
||||
// Should contain both progress lines (or at least be split correctly)
|
||||
if !bytes.Contains(data, []byte("progress: 50%")) {
|
||||
t.Errorf("Expected output to contain 'progress: 50%%', got %q", data)
|
||||
@@ -94,7 +94,7 @@ func TestTinyLog_LongLineCut(t *testing.T) {
|
||||
// Our logic finds the last safe boundary before maxLogBufferLen.
|
||||
// RuneStart(E4) at maxLogBufferLen-1 is true. FullRune(E4 at maxLogBufferLen-1 in payload[:maxLogBufferLen]) is false.
|
||||
// So lastSafe should be maxLogBufferLen-1.
|
||||
|
||||
|
||||
// The first maxLogBufferLen-1 bytes (all 'A') should be processed.
|
||||
// The "你" should be in remainder.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user