From 055ed27db77d799e790f22c95e29b82111d16b9d Mon Sep 17 00:00:00 2001 From: Zahoor Mohamed Date: Thu, 8 Aug 2019 23:31:02 +0530 Subject: [PATCH] Fix review comments by Janos --- api/http/server.go | 20 ++++++++++---------- api/http/server_test.go | 13 +++++++++++++ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/api/http/server.go b/api/http/server.go index 074caf5fcc..aef7ede2c8 100644 --- a/api/http/server.go +++ b/api/http/server.go @@ -168,13 +168,6 @@ func NewServer(api *api.API, pinAPI *pin.API, corsString string) *Server { defaultMiddlewares..., ), }) - mux.Handle("/", methodHandler{ - "GET": Adapt( - http.HandlerFunc(server.HandleRootPaths), - SetRequestID, - InitLoggingResponseWriter, - ), - }) mux.Handle("/bzz-pin:/", methodHandler{ "GET": Adapt( http.HandlerFunc(server.HandleGetPins), @@ -189,6 +182,13 @@ func NewServer(api *api.API, pinAPI *pin.API, corsString string) *Server { defaultMiddlewares..., ), }) + mux.Handle("/", methodHandler{ + "GET": Adapt( + http.HandlerFunc(server.HandleRootPaths), + SetRequestID, + InitLoggingResponseWriter, + ), + }) server.Handler = c.Handler(mux) return server @@ -930,10 +930,10 @@ func (s *Server) HandlePin(w http.ResponseWriter, r *http.Request) { return } - isRaw := true + isRaw := false isRawString := r.URL.Query().Get("IsRaw") - if isRawString == "" || isRawString == "false" { - isRaw = false + if strings.ToLower(isRawString) == "true" { + isRaw = true } err := s.pinAPI.PinFiles(fileAddr, isRaw, "") diff --git a/api/http/server_test.go b/api/http/server_test.go index 29a953e8bd..b9f19f662d 100644 --- a/api/http/server_test.go +++ b/api/http/server_test.go @@ -124,6 +124,19 @@ func TestPinUnpinAPI(t *testing.T) { if string(unpinMessage) != expectedunPinMsg { t.Fatalf("pin message mismatch, expected %x, got %x", expectedunPinMsg, unpinMessage) } + + // get the list of files pinned again + unpinnedInfo := listPinnedFiles(t, srv) + listInfosUnpin := make([]pin.FileInfo, 0) + err = json.Unmarshal(unpinnedInfo, &listInfosUnpin) + if err != nil { + t.Fatal(err) + } + + // Check if the pinned file is not present in the list pin command + if len(listInfosUnpin) != 0 { + t.Fatalf("roothash is in list of pinned files") + } } // Test the transparent resolving of feed updates with bzz:// scheme