lib/zold/commands/remote.rb in zold-0.22.4 vs lib/zold/commands/remote.rb in zold-0.22.5
- old
+ new
@@ -267,28 +267,11 @@
update_one(r, opts) do |json, score|
r.assert_valid_score(score)
r.assert_score_ownership(score)
r.assert_score_strength(score) unless opts['ignore-score-weakness']
@remotes.rescore(score.host, score.port, score.value)
- if Semantic::Version.new(VERSION) < Semantic::Version.new(json['version'])
- if opts['reboot']
- @log.info("#{r}: their version #{json['version']} is higher than mine #{VERSION}, reboot! \
- (use --never-reboot to avoid this from happening)")
- terminate
- end
- @log.debug("#{r}: their version #{json['version']} is higher than mine #{VERSION}, \
- it's recommended to reboot, but I don't do it because of --never-reboot")
- end
- if Semantic::Version.new(VERSION) < Semantic::Version.new(Zold::Gem.new.last_version)
- if opts['reboot']
- @log.info("#{r}: the version of the gem is higher than mine #{VERSION}, reboot! \
- (use --never-reboot to avoid this from happening)")
- terminate
- end
- @log.debug("#{r}: gem version is higher than mine #{VERSION}, \
- it's recommended to reboot, but I don't do it because of --never-reboot")
- end
+ reboot(r, json, opts)
if cycle.positive?
json['all'].each do |s|
next if @remotes.exists?(s['host'], s['port'])
add(s['host'], s['port'], opts)
end
@@ -326,9 +309,33 @@
@log.error("#{r} failed to read, trying again (attempt no.#{attempt}): #{e.message}")
retry
end
raise e
end
+ end
+
+ def reboot(r, json, opts)
+ return unless json['repo'] == Zold::REPO
+ mine = Semantic::Version.new(VERSION)
+ if mine < Semantic::Version.new(json['version'])
+ if opts['reboot']
+ @log.info("#{r}: their version #{json['version']} is higher than mine #{VERSION}, reboot! \
+(use --never-reboot to avoid this from happening)")
+ terminate
+ end
+ @log.debug("#{r}: their version #{json['version']} is higher than mine #{VERSION}, \
+it's recommended to reboot, but I don't do it because of --never-reboot")
+ end
+ if mine < Semantic::Version.new(Zold::Gem.new.last_version)
+ if opts['reboot']
+ @log.info("#{r}: the version of the gem is higher than mine #{VERSION}, reboot! \
+(use --never-reboot to avoid this from happening)")
+ terminate
+ end
+ @log.debug("#{r}: gem version is higher than mine #{VERSION}, \
+it's recommended to reboot, but I don't do it because of --never-reboot")
+ end
+ @log.debug("#{r}: gem version is lower or equal to mine #{VERSION}, no need to reboot")
end
def select(opts)
selected = @remotes.all.sort_by { |r| r[:score] }.reverse.first(opts['max-nodes'])
(@remotes.all - selected).each do |r|