Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/windows case sensitivity #22653

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions x-pack/elastic-agent/CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- Fix deb/rpm packaging for Elastic Agent {pull}22153[22153]
- Fix composable input processor promotion to fix duplicates {pull}22344[22344]
- Fix sysv init files for deb/rpm installation {pull}22543[22543]
- Fix uninstall issue on Windows when the capitalization of the path is different. {issue}22268[22268]

==== New features

Expand Down
11 changes: 11 additions & 0 deletions x-pack/elastic-agent/pkg/agent/install/installed.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ package install
import (
"os"
"path/filepath"
"runtime"
"strings"

"github.com/kardianos/service"
)
Expand Down Expand Up @@ -58,6 +60,15 @@ func RunningInstalled() bool {
execDir = filepath.Dir(filepath.Dir(execDir))
execPath = filepath.Join(execDir, execName)
}

// Windows filesystem is case insensitive and the following paths are the same.
// - C:\TMP
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can extract this to paths package and compare paths using paths.AreEqual or something similar

// - c:\tmp
// - c:\TMP
if runtime.GOOS == "windows" {
return strings.ToLower(expected) == strings.ToLower(execPath)
}

return expected == execPath
}

Expand Down