Skip to content

Commit

Permalink
Merge pull request #31 from MrLYC/fix-downloader
Browse files Browse the repository at this point in the history
fix download search
  • Loading branch information
MrLYC authored Sep 11, 2024
2 parents a688705 + 0f23545 commit 94873c5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.19.x]
go-version: [1.22.x]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19.x
go-version: 1.22.x
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --rm-dist --timeout 2h
args: release --timeout 2h
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.19.x]
go-version: [1.22.x]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down
7 changes: 4 additions & 3 deletions core/manager/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ func (m *DownloadManager) SetReplacements(replacements utils.Replacements) {

func (m *DownloadManager) search(name, output string) (string, error) {
files := utils.NewSortedHeap(1)
nameLength := float64(len(name))
nameLower := strings.ToLower(name)
nameLength := float64(len(nameLower))

err := filepath.Walk(output, func(path string, info fs.FileInfo, err error) error {
if err != nil {
Expand All @@ -39,11 +40,11 @@ func (m *DownloadManager) search(name, output string) (string, error) {

score := 0.0
if info.Mode()&0111 != 0 {
score = 0.1 / nameLength // perfer to choose executable file
score = 0.1 / nameLength // prefer to choose executable file
}

file := filepath.Base(path)
if strings.Contains(file, name) {
if strings.Contains(strings.ToLower(file), nameLower) {
score += nameLength / float64(len(file))
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/mrlyc/cmdr

go 1.19
go 1.22

require (
github.com/ahmetb/go-linq/v3 v3.2.0
Expand Down

0 comments on commit 94873c5

Please sign in to comment.