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

[Bug] File.exists return true when agent.exe doesn't exist but agent folder exist. #904

Merged
merged 5 commits into from
Oct 31, 2023
Merged
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
4 changes: 2 additions & 2 deletions libraries/recipe_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ def must_reinstall?(node)

include Chef::Mixin::ShellOut
def agent_get_version
return nil unless File.exist?(WIN_BIN_PATH)
return nil unless File.file?(WIN_BIN_PATH)
shell_out("\"#{WIN_BIN_PATH}\" version -n").stdout.strip
end

def fetch_current_version
raw_version = agent_get_version
return nil if raw_version.nil?
match_data = raw_version.match(/^Agent ([^\s]*) (- Meta: ([^\s]*) )?- Commit/)

# will fail if raw_version is empty (agent_get_version cmd fails)
version = match_data[1] if match_data
nightly_version = match_data[3] if match_data[2]
# If the Meta tag is catched, we'll add it to the version to specify the nightly version we're using
Expand Down