mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-22 17:10:51 +00:00
Upgrade bleve from v2.0.6 to v2.3.0 (#18132)
This commit is contained in:
parent
1a4e2bfcd1
commit
25a290e320
70 changed files with 1283 additions and 660 deletions
48
vendor/github.com/blevesearch/bleve/v2/index_impl.go
generated
vendored
48
vendor/github.com/blevesearch/bleve/v2/index_impl.go
generated
vendored
|
@ -18,7 +18,9 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
@ -910,3 +912,49 @@ func (m *searchHitSorter) Less(i, j int) bool {
|
|||
c := m.sort.Compare(m.cachedScoring, m.cachedDesc, m.hits[i], m.hits[j])
|
||||
return c < 0
|
||||
}
|
||||
|
||||
func (i *indexImpl) CopyTo(d index.Directory) (err error) {
|
||||
i.mutex.RLock()
|
||||
defer i.mutex.RUnlock()
|
||||
|
||||
if !i.open {
|
||||
return ErrorIndexClosed
|
||||
}
|
||||
|
||||
indexReader, err := i.i.Reader()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if cerr := indexReader.Close(); err == nil && cerr != nil {
|
||||
err = cerr
|
||||
}
|
||||
}()
|
||||
|
||||
irc, ok := indexReader.(IndexCopyable)
|
||||
if !ok {
|
||||
return fmt.Errorf("index implementation does not support copy")
|
||||
}
|
||||
|
||||
err = irc.CopyTo(d)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error copying index metadata: %v", err)
|
||||
}
|
||||
|
||||
// copy the metadata
|
||||
return i.meta.CopyTo(d)
|
||||
}
|
||||
|
||||
func (f FileSystemDirectory) GetWriter(filePath string) (io.WriteCloser,
|
||||
error) {
|
||||
dir, file := filepath.Split(filePath)
|
||||
if dir != "" {
|
||||
err := os.MkdirAll(filepath.Join(string(f), dir), os.ModePerm)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return os.OpenFile(filepath.Join(string(f), dir, file),
|
||||
os.O_RDWR|os.O_CREATE, 0600)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue