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 df7cc0b453, so this CL is restoring it.

Fixes #619

Change-Id: I8e4762d1f5a2dba4f7cf06d8ca164392c4bf6d6a
This commit is contained in:
Mario Russo 2015-05-27 14:03:41 +02:00
parent 036f8b19af
commit 01cddcc8d5
2 changed files with 6 additions and 1 deletions

View File

@ -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
}

View File

@ -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.
}