MCPcopy Index your code
hub / github.com/perkeep/perkeep / serveFiles

Method serveFiles

pkg/search/handler.go:692–731  ·  view source on GitHub ↗
(rw http.ResponseWriter, req *http.Request)

Source from the content-addressed store, hash-verified

690}
691
692func (h *Handler) serveFiles(rw http.ResponseWriter, req *http.Request) {
693 var ret camtypes.FileSearchResponse
694 defer httputil.ReturnJSON(rw, &ret)
695
696 h.index.RLock()
697 defer h.index.RUnlock()
698
699 if err := req.ParseForm(); err != nil {
700 ret.Error = err.Error()
701 ret.ErrorType = "input"
702 return
703 }
704 values, ok := req.Form["wholedigest"]
705 if !ok {
706 ret.Error = "Missing 'wholedigest' param"
707 ret.ErrorType = "input"
708 return
709 }
710 var digests []blob.Ref
711 for _, v := range values {
712 br, ok := blob.Parse(v)
713 if !ok {
714 ret.Error = "Invalid 'wholedigest' param"
715 ret.ErrorType = "input"
716 return
717 }
718 digests = append(digests, br)
719 }
720
721 files, err := h.index.ExistingFileSchemas(digests...)
722 if err != nil {
723 ret.Error = err.Error()
724 ret.ErrorType = "server"
725 }
726 // the ui code expects an object
727 if files == nil {
728 files = make(index.WholeRefToFile)
729 }
730 ret.Files = files
731}
732
733// SignerAttrValueResponse is the JSON response to $search/camli/search/signerattrvalue
734type SignerAttrValueResponse struct {

Callers

nothing calls this directly

Calls 6

ReturnJSONFunction · 0.92
ParseFunction · 0.92
RLockMethod · 0.65
RUnlockMethod · 0.65
ExistingFileSchemasMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected