Skip to content

Commit

Permalink
fix(search): recovery when OpenCC panic
Browse files Browse the repository at this point in the history
  • Loading branch information
foamzou committed Mar 30, 2022
1 parent 34685c8 commit 5a9b3d6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Binaries for programs and plugins
*.exe
*.mp3
*.exe~
*.dll
*.so
Expand Down
2 changes: 1 addition & 1 deletion LATEST_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.1
0.2.2
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ WIN_BIN=.release/${BINARY_NAME}-${VERSION_NAME}-win.exe
release:
@printf "${VERSION_NAME}" > ./LATEST_VERSION
mkdir -p .release
CGO_ENABLED=0 GOARCH=amd64 GOOS=darwin go build -ldflags "-s -w" -o ${MAC_BIN} main.go
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags "-s -w" -o ${LINUX_BIN} main.go
CGO_ENABLED=0 GOARCH=amd64 GOOS=windows go build -ldflags "-s -w" -o ${WIN_BIN} main.go
CGO_ENABLED=0 GOARCH=amd64 GOOS=darwin go build -trimpath -ldflags "-s -w" -o ${MAC_BIN} main.go
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -trimpath -ldflags "-s -w" -o ${LINUX_BIN} main.go
CGO_ENABLED=0 GOARCH=amd64 GOOS=windows go build -trimpath -ldflags "-s -w" -o ${WIN_BIN} main.go
upx ${MAC_BIN}
upx ${LINUX_BIN}
upx ${WIN_BIN}
chmod +x ${MAC_BIN} ${LINUX_BIN}

build:
go build main.go
Expand Down
10 changes: 8 additions & 2 deletions processor/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,14 @@ func (p *Processor) outputSearchResult(searchItems []*meta.SearchSongItem) {
}
}

func convertTC2SC(occ *ccgo.OpenCC, in string) string {
out, _ := occ.Convert(in)
func convertTC2SC(occ *ccgo.OpenCC, in string) (out string) {
out = in
defer func() {
if err := recover(); err != nil {
return
}
}()
out, _ = occ.Convert(in)
if out == "" {
return in
}
Expand Down
4 changes: 2 additions & 2 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
)

const (
BuildCode = 6
BuildName = "0.2.1"
BuildCode = 7
BuildName = "0.2.2"
Repo = "https://github.com/foamzou/media-get"
)

Expand Down

0 comments on commit 5a9b3d6

Please sign in to comment.