more comprehensive value check

This commit is contained in:
Samir Patel 2021-11-01 18:19:38 -05:00
parent 1de6085782
commit 5206e8fa0e

View file

@ -2721,6 +2721,9 @@ func (h *Handler) handlePostImport(w http.ResponseWriter, r *http.Request) {
qcx := h.api.Txf().NewQcx()
defer qcx.Abort()
if isImportRequestEmpty(req) {
return
}
if err := h.api.ImportValue(r.Context(), qcx, req, opts...); err != nil {
switch errors.Cause(err) {
case pilosa.ErrClusterDoesNotOwnShard, pilosa.ErrPreconditionFailed:
@ -3463,3 +3466,8 @@ func (h *Handler) handlePostRestore(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte("OK")) //nolint:errcheck
}
func isImportRequestEmpty(req *pilosa.ImportValueRequest) bool {
totalData := len(req.Values) + len(req.FloatValues) + len(req.TimestampValues) + len(req.StringValues)
return totalData == 0
}