Add a Save to Mac button for files in the Files tab
This commit is contained in:
@@ -228,11 +228,24 @@ func (s *Server) GetTaskRaw(w http.ResponseWriter, r *http.Request, taskID strin
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if params.Path == "" {
|
||||
serveRaw(w, r, t.WorktreePath, params.Path)
|
||||
}
|
||||
|
||||
func (s *Server) GetProjectRaw(w http.ResponseWriter, r *http.Request, projectID string, params api.GetProjectRawParams) {
|
||||
p, err := s.store.GetProject(r.Context(), projectID)
|
||||
if err != nil {
|
||||
writeStoreError(w, err)
|
||||
return
|
||||
}
|
||||
serveRaw(w, r, p.RepoPath, params.Path)
|
||||
}
|
||||
|
||||
func serveRaw(w http.ResponseWriter, r *http.Request, root, rel string) {
|
||||
if rel == "" {
|
||||
writeError(w, http.StatusBadRequest, errors.New("path is required"))
|
||||
return
|
||||
}
|
||||
name, full := taskPath(t.WorktreePath, params.Path)
|
||||
name, full := taskPath(root, rel)
|
||||
|
||||
f, err := os.Open(full)
|
||||
if err != nil {
|
||||
@@ -247,7 +260,7 @@ func (s *Server) GetTaskRaw(w http.ResponseWriter, r *http.Request, taskID strin
|
||||
return
|
||||
}
|
||||
if !fi.Mode().IsRegular() {
|
||||
writeError(w, http.StatusBadRequest, fmt.Errorf("%s is not a regular file", params.Path))
|
||||
writeError(w, http.StatusBadRequest, fmt.Errorf("%s is not a regular file", rel))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user