From 01cddcc8d557d14fb3cba5de28871d4dbfefc26b Mon Sep 17 00:00:00 2001 From: Mario Russo Date: Wed, 27 May 2015 14:03:41 +0200 Subject: [PATCH] pkg/search: fix null "files" in file search response The "files" field of a file search response was always non-null (empty JSON array in case of error or no result). This behaviour was broken by df7cc0b45332a0ca7f762cbba3ab4133aaea2d5e, so this CL is restoring it. Fixes #619 Change-Id: I8e4762d1f5a2dba4f7cf06d8ca164392c4bf6d6a --- pkg/search/handler.go | 5 +++++ pkg/types/camtypes/search.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/search/handler.go b/pkg/search/handler.go index 14af2fd0d..dcee86322 100644 --- a/pkg/search/handler.go +++ b/pkg/search/handler.go @@ -661,6 +661,11 @@ func (sh *Handler) serveFiles(rw http.ResponseWriter, req *http.Request) { return } + // the ui code expects an object + if files == nil { + files = []blob.Ref{} + } + ret.Files = files return } diff --git a/pkg/types/camtypes/search.go b/pkg/types/camtypes/search.go index acc7ce2d2..c132680fa 100644 --- a/pkg/types/camtypes/search.go +++ b/pkg/types/camtypes/search.go @@ -250,5 +250,5 @@ type SearchErrorResponse struct { type FileSearchResponse struct { SearchErrorResponse - Files []blob.Ref `json:"files,omitempty"` // Refs of the result files. + Files []blob.Ref `json:"files"` // Refs of the result files. Never nil. }