mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-12 23:51:03 +00:00
applied ben's suggestions
This commit is contained in:
parent
05fea53f73
commit
ff86f82ef2
4 changed files with 14 additions and 15 deletions
18
api.go
18
api.go
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ func (cmd *RestoreCommand) Run(ctx context.Context) error {
|
|||
return err
|
||||
}
|
||||
default:
|
||||
panic("UNKNOWN " + record[0])
|
||||
return err
|
||||
|
||||
}
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
4
index.go
4
index.go
|
|
@ -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] }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue