diff --git a/Dockerfile b/Dockerfile index f720c79..1b9d44f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -79,7 +79,8 @@ COPY docker-entrypoint.sh . COPY sync.py /opt/sync.py RUN chmod +x /opt/sync.py \ && chmod +x docker-entrypoint.sh \ - && touch "dont-not-delete-anythings" + && touch "dont-not-delete-anythings" \ + && echo "set encoding=utf-8" >> /etc/vim/vimrc EXPOSE 8052 diff --git a/internal/services/executor_service.go b/internal/services/executor_service.go index f7f8318..ad8744f 100644 --- a/internal/services/executor_service.go +++ b/internal/services/executor_service.go @@ -12,6 +12,7 @@ import ( "fmt" "os" "os/exec" + "path/filepath" "strings" "sync" "time" @@ -354,12 +355,25 @@ func (es *ExecutorService) executeRepoTask(task *models.Task) *ExecutionResult { return result } + // 处理目标路径:为空则使用 scripts 目录,相对路径则基于 scripts 目录 + targetPath := config.TargetPath + if targetPath == "" { + targetPath = constant.ScriptsWorkDir + } else if !filepath.IsAbs(targetPath) { + targetPath = filepath.Join(constant.ScriptsWorkDir, targetPath) + } + // 转换为绝对路径 + absTargetPath, err := filepath.Abs(targetPath) + if err != nil { + absTargetPath = targetPath + } + // 构建 sync.py 命令参数 args := []string{ "/opt/sync.py", "--source-type", config.SourceType, "--source-url", config.SourceURL, - "--target-path", config.TargetPath, + "--target-path", absTargetPath, } // Git 分支 diff --git a/sync.py b/sync.py index c264c2c..5e7f3a3 100644 --- a/sync.py +++ b/sync.py @@ -255,6 +255,9 @@ def main(): args = parser.parse_args() + # 打印原始命令行参数 + print("参数:", " ".join(sys.argv[1:])) + if args.source_type == "git": sync_git(args) else: