MCPcopy
hub / github.com/syncthing/syncthing / getDBFile

Method getDBFile

lib/api/api.go:918–959  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

916}
917
918func (s *service) getDBFile(w http.ResponseWriter, r *http.Request) {
919 qs := r.URL.Query()
920 folder := qs.Get("folder")
921 file := qs.Get("file")
922
923 errStatus := http.StatusInternalServerError
924 gf, gfOk, err := s.model.CurrentGlobalFile(folder, file)
925 if err != nil {
926 if isFolderNotFound(err) {
927 errStatus = http.StatusNotFound
928 }
929 http.Error(w, err.Error(), errStatus)
930 return
931 }
932
933 lf, lfOk, err := s.model.CurrentFolderFile(folder, file)
934 if err != nil {
935 if isFolderNotFound(err) {
936 errStatus = http.StatusNotFound
937 }
938 http.Error(w, err.Error(), errStatus)
939 return
940 }
941
942 if !(gfOk || lfOk) {
943 // This file for sure does not exist.
944 http.Error(w, "No such object in the index", http.StatusNotFound)
945 return
946 }
947
948 av, err := s.model.Availability(folder, gf, protocol.BlockInfo{})
949 if err != nil {
950 http.Error(w, err.Error(), http.StatusInternalServerError)
951 return
952 }
953
954 sendJSON(w, map[string]interface{}{
955 "global": jsonFileInfo(gf),
956 "local": jsonFileInfo(lf),
957 "availability": av,
958 })
959}
960
961func (s *service) getDebugFile(w http.ResponseWriter, r *http.Request) {
962 qs := r.URL.Query()

Callers

nothing calls this directly

Calls 8

isFolderNotFoundFunction · 0.85
sendJSONFunction · 0.85
jsonFileInfoTypeAlias · 0.85
GetMethod · 0.65
CurrentGlobalFileMethod · 0.65
ErrorMethod · 0.65
CurrentFolderFileMethod · 0.65
AvailabilityMethod · 0.65

Tested by

no test coverage detected