This commit is contained in:
Anya Tokugawa committed 2026-05-19 21:30:42 +09:00
commit fa6a4c650f
93 files changed
+6555

No files matched your search

+76
View File
@@ -0,0 +1,76 @@
package server
import (
"encoding/json"
"net/http"
)
type renamePreviewResponse struct {
Targets []string `json:"targets"`
}
func (s *Server) handleRenamePreview(
w http.ResponseWriter,
r *http.Request,
) {
oldPath :=
r.URL.Query().Get(
"old_path",
)
rows, err :=
s.store.DB.Query(`
SELECT path
FROM paths
WHERE path = ?
OR path LIKE ?
ORDER BY LENGTH(path) ASC
`,
oldPath,
oldPath+"/%",
)
if err != nil {
http.Error(
w,
err.Error(),
500,
)
return
}
defer rows.Close()
var targets []string
for rows.Next() {
var p string
err := rows.Scan(&p)
if err != nil {
continue
}
targets =
append(
targets,
p,
)
}
w.Header().Set(
"Content-Type",
"application/json",
)
json.NewEncoder(w).Encode(
renamePreviewResponse{
Targets: targets,
},
)
}