mirror of
https://github.com/PeernetOfficial/core.git
synced 2026-07-23 05:07:51 +01:00
webapi: /file/view add parameter 'nocache' to force download from remote peer. This is useful for testing purposes.
This commit is contained in:
@@ -170,6 +170,7 @@ func apiFileView(w http.ResponseWriter, r *http.Request) {
|
|||||||
offset, _ := strconv.Atoi(r.Form.Get("offset"))
|
offset, _ := strconv.Atoi(r.Form.Get("offset"))
|
||||||
limit, _ := strconv.Atoi(r.Form.Get("limit"))
|
limit, _ := strconv.Atoi(r.Form.Get("limit"))
|
||||||
format, _ := strconv.Atoi(r.Form.Get("format"))
|
format, _ := strconv.Atoi(r.Form.Get("format"))
|
||||||
|
localCacheDisable, _ := strconv.ParseBool(r.Form.Get("nocache"))
|
||||||
|
|
||||||
// Range header?
|
// Range header?
|
||||||
var ranges []HTTPRange
|
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.
|
// 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) {
|
if !localCacheDisable {
|
||||||
return
|
if serveFileFromWarehouse(w, fileHash, uint64(offset), uint64(limit), ranges) {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// try connecting via node ID or peer ID?
|
// try connecting via node ID or peer ID?
|
||||||
|
|||||||
Reference in New Issue
Block a user