more detailed update exception

This commit is contained in:
Christian Mehlmauer
2016-08-12 20:54:24 +02:00
parent 19b15b5327
commit 22d69a1bf9
3 changed files with 30 additions and 1 deletions

View File

@@ -80,6 +80,15 @@ class DbUpdater
local_file_checksum(filename)
end
def get_cloudflare_info
begin
res = Browser.get(remote_file_url('/cdn-cgi/trace'), request_params)
res.body
rescue
nil
end
end
def update(verbose = false)
FILES.each do |filename|
begin
@@ -101,7 +110,7 @@ class DbUpdater
puts " [i] Database File Checksum : #{db_checksum}" if verbose
unless dl_checksum == db_checksum
fail "#{filename}: checksums do not match (local: #{dl_checksum} remote: #{db_checksum})"
raise ChecksumError.new(File.read(local_file_path(filename)), get_cloudflare_info), "#{filename}: checksums do not match (local: #{dl_checksum} remote: #{db_checksum})"
end
rescue => e
puts ' [i] Restoring Backup due to error' if verbose

View File

@@ -31,3 +31,12 @@ class DownloadError < HttpError
"Unable to get #{failure_details}"
end
end
class ChecksumError < StandardError
attr_reader :file, :cloudflare_info
def initialize(file, cloudflare_info)
@file = file
@cloudflare_info = cloudflare_info
end
end