Let pages in the page view load their local files

This commit is contained in:
Ian Gulliver
2026-10-23 05:44:19 -07:00
parent dfb114ea64
commit d391b41bf6
5 changed files with 510 additions and 472 deletions
+5 -9
View File
@@ -226,16 +226,12 @@ func serveFile(w http.ResponseWriter, root, rel string) {
writeJSON(w, http.StatusOK, fc)
}
func (s *Server) GetTaskRaw(w http.ResponseWriter, r *http.Request, taskID string, params api.GetTaskRawParams) {
t, ok := s.activeTask(w, r, taskID)
if !ok {
func (s *Server) GetRaw(w http.ResponseWriter, r *http.Request, params api.GetRawParams) {
full := filepath.Clean(filepath.FromSlash(params.Path))
if !filepath.IsAbs(full) {
writeError(w, http.StatusBadRequest, errors.New("path must be absolute"))
return
}
if params.Path == "" {
writeError(w, http.StatusBadRequest, errors.New("path is required"))
return
}
name, full := taskPath(t.WorktreePath, params.Path)
f, err := os.Open(full)
if err != nil {
@@ -254,7 +250,7 @@ func (s *Server) GetTaskRaw(w http.ResponseWriter, r *http.Request, taskID strin
return
}
contentType := mime.TypeByExtension(path.Ext(name))
contentType := mime.TypeByExtension(filepath.Ext(full))
if contentType == "" {
contentType = "application/octet-stream"
}