webapi: /file/view add parameter 'nocache' to force download from remote peer. This is useful for testing purposes.

This commit is contained in:
Kleissner
2021-12-13 16:52:13 +01:00
parent cab881ebdb
commit f18e651f40

View File

@@ -170,6 +170,7 @@ func apiFileView(w http.ResponseWriter, r *http.Request) {
offset, _ := strconv.Atoi(r.Form.Get("offset"))
limit, _ := strconv.Atoi(r.Form.Get("limit"))
format, _ := strconv.Atoi(r.Form.Get("format"))
localCacheDisable, _ := strconv.ParseBool(r.Form.Get("nocache"))
// Range header?
var ranges []HTTPRange
@@ -192,8 +193,10 @@ func apiFileView(w http.ResponseWriter, r *http.Request) {
}
// Is the file available in the local warehouse? In that case requesting it from the remote is unnecessary.
if serveFileFromWarehouse(w, fileHash, uint64(offset), uint64(limit), ranges) {
return
if !localCacheDisable {
if serveFileFromWarehouse(w, fileHash, uint64(offset), uint64(limit), ranges) {
return
}
}
// try connecting via node ID or peer ID?