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 3 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
6 changes: 3 additions & 3 deletions libraries/recipe_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
Pythyu marked this conversation as resolved.
Show resolved Hide resolved

# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
Expand Down 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 (Line 199 fails)
Pythyu marked this conversation as resolved.
Show resolved Hide resolved
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