Skip to content

Commit

Permalink
fix#12修复删除bug
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoK29 committed May 19, 2022
1 parent f50a0ae commit 90f66cc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
20 changes: 5 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,36 @@ require (
github.com/gin-gonic/gin v1.7.7
github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46
github.com/shirou/gopsutil/v3 v3.22.4
github.com/spf13/viper v1.11.0
github.com/syndtr/goleveldb v1.0.0
github.com/wangbin/jiebago v0.3.2
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-playground/locales v0.13.0 // indirect
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/go-playground/validator/v10 v10.4.1 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pelletier/go-toml/v2 v2.0.0-beta.8 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/ugorji/go/codec v1.1.7 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 // indirect
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
14 changes: 3 additions & 11 deletions searcher/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"gofound/searcher/storage"
"gofound/searcher/utils"
"gofound/searcher/words"
"io/ioutil"

"log"
"os"
"path"

"runtime"
"strings"
"sync"
Expand Down Expand Up @@ -539,17 +539,9 @@ func (e *Engine) Drop() error {
e.Lock()
defer e.Unlock()
//删除文件
dir, err := ioutil.ReadDir(e.IndexPath)
if err != nil {
if err := os.RemoveAll(e.IndexPath); err != nil {
return err
}
for _, d := range dir {
err := os.RemoveAll(path.Join([]string{d.Name()}...))
if err != nil {
return err
}
os.Remove(e.IndexPath)
}

//清空内存
for i := 0; i < e.Shard; i++ {
Expand Down

0 comments on commit 90f66cc

Please sign in to comment.