Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
bot.mirror: check the last package information
Browse files Browse the repository at this point in the history
  • Loading branch information
icy committed Oct 30, 2014
1 parent 7dc88eb commit f06dc3d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions bot/plugins/mirror.rb
Expand Up @@ -44,6 +44,14 @@ def mirror_monitor(m, cache_time = 1800)
m.reply "!! Error: Invalid curl data found" \
if _cache_expired?(:mirror, "cron_error", :cache_time => cache_time)
end

offset = Time.now - Time.parse(@curl_data["f"]["the_latest_package_time"])
offset = (offset / 3600).to_i
if offset > 24
m.reply "!! Warning: The last package is updated #{offset} hours ago" \
if _cache_expired?(:mirror, "cron_warn_lastpkg", :cache_time => cache_time)
end

return @curl_data
end

Expand Down Expand Up @@ -86,13 +94,15 @@ def mirror_status(m, msg)
end

@curl_data = mirror_cron(m)
offset = Time.now - Time.parse(@curl_data["f"]["the_latest_package_time"])
offset = (offset / 60).to_i

echo = case msg.strip
when "config" then @curl_data["f"]["mirror_config"] || "error"
when "status" then
sprintf("updated %s (up %s); size: %s; FPT updated %s", \
sprintf("synced @ %s (last package: %s minutes ago); size: %s; FPT synced @ %s", \
@curl_data["f"]["report_time"],
@curl_data["f"]["number_of_updated_packages"],
offset,
@curl_data["f"]["repo_total_size_in_name"],
@curl_data["fpt"])
end
Expand Down

0 comments on commit f06dc3d

Please sign in to comment.