mirror of https://github.com/perkeep/perkeep.git
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:
parent
036f8b19af
commit
01cddcc8d5
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue