Merge pull request #2104 from sundy-li/holder-fix

holder.go: fix some logic errors
This commit is contained in:
Kuba Podgórski 2020-04-29 11:14:11 +02:00 • committed by GitHub
commit 1b3d0fd8a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -145,13 +145,6 @@ func (h *Holder) Open() error {
return errors.Wrap(err, "creating directory")
}
// Verify that we are not trying to open with v1 translation data.
if ok, err := h.hasV1TranslateKeysFile(); err != nil {
return errors.Wrap(err, "verify v1 translation file")
} else if !ok {
return ErrCannotOpenV1TranslateFile
}
// Open path to read all index directories.
f, err := os.Open(h.Path)
if err != nil {
@ -278,16 +271,6 @@ func (h *Holder) HasData() (bool, error) {
return false, nil
}
// hasV1TranslateKeysFile returns true if a v1 translation data file exists on disk.
func (h *Holder) hasV1TranslateKeysFile() (bool, error) {
if _, err := os.Stat(filepath.Join(h.Path, ".keys")); os.IsNotExist(err) {
return true, nil
} else if err != nil {
return false, err
}
return false, nil
}
// availableShardsByIndex returns a bitmap of all shards by indexes.
func (h *Holder) availableShardsByIndex() map[string]*roaring.Bitmap {
m := make(map[string]*roaring.Bitmap)