mirror of https://github.com/perkeep/perkeep.git
server/filetree: do not defer standard response
Because we don't want to send it in the error case. Address comments from https://camlistore-review.googlesource.com/#/c/4957/2/pkg/server/filetree.go Change-Id: I96ea90a8430299fb21038b5d7b794098c40d95b1
This commit is contained in:
parent
0655295771
commit
1af881a3f2
|
@ -54,9 +54,6 @@ func (fth *FileTreeHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
|
|||
return
|
||||
}
|
||||
|
||||
var ret FileTreeResponse
|
||||
defer httputil.ReturnJSON(rw, &ret)
|
||||
|
||||
de, err := schema.NewDirectoryEntryFromBlobRef(fth.Fetcher, fth.file)
|
||||
if err != nil {
|
||||
http.Error(rw, "Error reading directory", 500)
|
||||
|
@ -75,7 +72,10 @@ func (fth *FileTreeHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
|
|||
log.Printf("reading dir from blobref %s: %v\n", fth.file, err)
|
||||
return
|
||||
}
|
||||
ret.Children = make([]FileTreeNode, 0, len(entries))
|
||||
|
||||
var ret = FileTreeResponse{
|
||||
Children: make([]FileTreeNode, 0, len(entries)),
|
||||
}
|
||||
for _, v := range entries {
|
||||
ret.Children = append(ret.Children, FileTreeNode{
|
||||
Name: v.FileName(),
|
||||
|
@ -83,4 +83,5 @@ func (fth *FileTreeHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
|
|||
BlobRef: v.BlobRef(),
|
||||
})
|
||||
}
|
||||
httputil.ReturnJSON(rw, ret)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue