summaryrefslogtreecommitdiff
path: root/lib/chef/provider/package.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2018-09-27 23:07:50 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2018-09-27 23:07:50 -0700
commite2cab3ba7e06c84f2748f86db51a900b7f60bbf1 (patch)
treeb9dfbf4064b6711969e1f969a08dc7a21d4694af /lib/chef/provider/package.rb
parentada1b38637c5771afbf95de9498ccdea23eb4cf9 (diff)
downloadchef-e2cab3ba7e06c84f2748f86db51a900b7f60bbf1.tar.gz
short circuit before the version_compare calllcg/short-circuit-version-compare
combined with the other PRs this will make most of the subclasses never even call version_compare now. the subclasses that need allow_downgrade as a feature should implement both the property and implement version_compare now. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/provider/package.rb')
-rw-r--r--lib/chef/provider/package.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb
index 534a219ff5..f6172f1edf 100644
--- a/lib/chef/provider/package.rb
+++ b/lib/chef/provider/package.rb
@@ -496,7 +496,7 @@ class Chef
elsif current_version.nil?
logger.trace("#{new_resource} has no existing installed version. Installing install #{candidate_version}")
target_version_array.push(candidate_version)
- elsif version_compare(current_version, candidate_version) == 1 && !allow_downgrade
+ elsif !allow_downgrade && version_compare(current_version, candidate_version) == 1
logger.trace("#{new_resource} #{package_name} has installed version #{current_version}, which is newer than available version #{candidate_version}. Skipping...)")
target_version_array.push(nil)
else