From f18e651f40daaae7591e6ed802d2eb8dc9bf5099 Mon Sep 17 00:00:00 2001 From: Kleissner Date: Mon, 13 Dec 2021 16:52:13 +0100 Subject: [PATCH] webapi: /file/view add parameter 'nocache' to force download from remote peer. This is useful for testing purposes. --- webapi/File IO.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/webapi/File IO.go b/webapi/File IO.go index ddf3d3d..e60b628 100644 --- a/webapi/File IO.go +++ b/webapi/File IO.go @@ -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?