mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-06 19:07:50 +00:00
don't explode on translate data restore for _keys
There isn't really a field called _keys but some old backups will think they have translate data for this. Ignore it politely. Also in general produce a diagnostic rather than a panic for translate data restores to nonexistent indexes or fields.
This commit is contained in:
parent
73f3c01284
commit
7270016d1a
1 changed files with 21 additions and 0 deletions
21
api.go
21
api.go
|
|
@ -2643,7 +2643,13 @@ func (api *API) RestoreIDAlloc(r io.Reader) error {
|
|||
// rd is a boltdb file.
|
||||
func (api *API) TranslateIndexDB(ctx context.Context, indexName string, partitionID int, rd io.Reader) error {
|
||||
idx := api.holder.Index(indexName)
|
||||
if idx == nil {
|
||||
return fmt.Errorf("index %q not found", indexName)
|
||||
}
|
||||
store := idx.TranslateStore(partitionID)
|
||||
if store == nil {
|
||||
return fmt.Errorf("index %q has no translate store", indexName)
|
||||
}
|
||||
_, err := store.ReadFrom(rd)
|
||||
return err
|
||||
}
|
||||
|
|
@ -2651,8 +2657,23 @@ func (api *API) TranslateIndexDB(ctx context.Context, indexName string, partitio
|
|||
// TranslateFieldDB is an internal function to load the field keys database
|
||||
func (api *API) TranslateFieldDB(ctx context.Context, indexName, fieldName string, rd io.Reader) error {
|
||||
idx := api.holder.Index(indexName)
|
||||
if idx == nil {
|
||||
return fmt.Errorf("index %q not found", indexName)
|
||||
}
|
||||
field := idx.Field(fieldName)
|
||||
if field == nil {
|
||||
// Older versions used to accidentally provide an empty translation
|
||||
// data file for a nonexistent field called "_keys". To make migration
|
||||
// easier, we politely ignore that.
|
||||
if fieldName == "_keys" {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("field %q/%q not found", indexName, fieldName)
|
||||
}
|
||||
store := field.TranslateStore()
|
||||
if store == nil {
|
||||
return fmt.Errorf("field %q/%q has no translate store", indexName, fieldName)
|
||||
}
|
||||
_, err := store.ReadFrom(rd)
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue