(w http.ResponseWriter, r *http.Request)
| 916 | } |
| 917 | |
| 918 | func (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 | |
| 961 | func (s *service) getDebugFile(w http.ResponseWriter, r *http.Request) { |
| 962 | qs := r.URL.Query() |
nothing calls this directly
no test coverage detected