feat: harden workspace file APIs

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
tao.chen
2026-07-02 17:22:26 +08:00
co-authored by Claude Fable 5
parent c1b8982e3b
commit 04b309d3fc
18 changed files with 1262 additions and 76 deletions
+22
View File
@@ -2,6 +2,7 @@ package api
import (
"net/http"
"time"
"codespace/internal/model"
"codespace/internal/service"
@@ -112,3 +113,24 @@ func (h *fileHandler) rename(c *gin.Context) {
}
c.Status(http.StatusNoContent)
}
func (h *fileHandler) stat(c *gin.Context) {
id := c.Param("id")
path := c.Query("path")
if path == "" {
writeBadRequest(c, "path is required")
return
}
info, err := h.svc.Stat(id, path)
if err != nil {
writeError(c, err)
return
}
c.JSON(http.StatusOK, model.FileInfoResponse{
Name: info.Name,
Path: info.Path,
IsDir: info.IsDir,
Size: info.Size,
ModTime: info.ModTime.Format(time.RFC3339Nano),
})
}