applied ben's suggestions

This commit is contained in:
Todd Gruben 2021-05-23 10:27:50 -05:00
parent 05fea53f73
commit ff86f82ef2
4 changed files with 14 additions and 15 deletions

18
api.go
View file

@ -2246,11 +2246,19 @@ func (api *API) RestoreShard(ctx context.Context, indexName string, shard uint64
if err != nil {
return err
}
w := bufio.NewWriter(o)
//close db if open
_, err = io.Copy(w, rd)
w.Flush()
o.Close()
defer o.Close()
bw := bufio.NewWriter(o)
if _, err = io.Copy(bw, rd); err != nil {
return err
} else if err := bw.Flush(); err != nil {
return err
} else if err := o.Sync(); err != nil {
return err
} else if err := o.Close(); err != nil {
return err
}
if err != nil {
_ = os.Remove(tempPath)
return err

View file

@ -120,7 +120,7 @@ func (cmd *RestoreCommand) Run(ctx context.Context) error {
return err
}
default:
panic("UNKNOWN " + record[0])
return err
}
continue

View file

@ -2924,11 +2924,6 @@ func (h *Handler) handleRestoreIDAlloc(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("OK")) //nolint:errcheck
}
func (h *Handler) handlePostRestore(w http.ResponseWriter, r *http.Request) {
/*
if !validHeaderAcceptType(r.Header, "text", "plain") {
http.Error(w, "text/plain is not an acceptable response type", http.StatusNotAcceptable)
}
*/
indexName, ok := mux.Vars(r)["index"]
if !ok {
http.Error(w, "index name is required", http.StatusBadRequest)

View file

@ -814,10 +814,6 @@ func (i *Index) DeleteField(name string) error {
return i.translationSyncer.Reset()
}
func (i *Index) UpdateAvailbleShards(field, view string, shard uint64) {
}
type indexSlice []*Index
func (p indexSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }