MCPcopy Create free account
hub / github.com/couchbase/cbft / streamPIndexContents

Method streamPIndexContents

rest_pindex_streamer.go:114–138  ·  view source on GitHub ↗
(pindexName string,
	w http.ResponseWriter, req *http.Request)

Source from the content-addressed store, hash-verified

112}
113
114func (h *PIndexContentHandler) streamPIndexContents(pindexName string,
115 w http.ResponseWriter, req *http.Request) {
116 pindexPath := h.mgr.PIndexPath(pindexName)
117 _, err := ioutil.ReadDir(pindexPath)
118 if err != nil {
119 rest.ShowError(w, req, fmt.Sprintf("rest_pindex_streamer:"+
120 " read failed for path: %s, err: %v", pindexPath, err),
121 http.StatusInternalServerError)
122 return
123 }
124
125 size, err := cbgt.GetDirectorySize(pindexPath)
126 if err != nil {
127 rest.ShowError(w, req, fmt.Sprintf("rest_pindex_streamer:"+
128 " GetDirectorySize failed for path: %s, err: %v",
129 pindexPath, err), http.StatusInternalServerError)
130 return
131 }
132
133 w.Header().Set("Content-Size", strconv.Itoa(int(size)))
134 w.Header().Set("Content-Type", "application/x-tar")
135 w.Header().Set("Trailer", "Checksum")
136
137 h.streamTarArchive(pindexName, w, req)
138}
139
140func (h *PIndexContentHandler) streamTarArchive(pindexName string,
141 w http.ResponseWriter, req *http.Request) {

Callers 1

ServeHTTPMethod · 0.95

Calls 2

streamTarArchiveMethod · 0.95
HeaderMethod · 0.80

Tested by

no test coverage detected