diff --git a/helpers.rb b/helpers.rb index 8c0f340..4ae8f77 100644 --- a/helpers.rb +++ b/helpers.rb @@ -93,7 +93,7 @@ def http_request(method, address, options={}, &block) end def sync_client_update_available - log :yellow, "Checking if PTSync-rb is up to date..." + log "Checking if PTSync-rb is up to date..." http_request :get, 'http://germ.intoxicated.co.za/ns2/ptsync/version.json', allow_failure: true do |http, response| if response yield response['version'] > PT_SYNC_VERSION, response['files'] diff --git a/ptsync.rb b/ptsync.rb index 41dbc85..7fea49b 100644 --- a/ptsync.rb +++ b/ptsync.rb @@ -12,7 +12,7 @@ require 'pp' require './helpers' -PT_SYNC_VERSION = 0.9 +PT_SYNC_VERSION = 1.0 $git_repo = File.directory?('./.git') diff --git a/sync.rb b/sync.rb index a142491..8c57cf6 100644 --- a/sync.rb +++ b/sync.rb @@ -23,6 +23,7 @@ Dir.chdir('../') if $packaged #YAML::ENGINE.yamler = 'syck' +Encoding.default_external = 'utf-8' initialize_config @@ -192,6 +193,8 @@ def download_files(sub_paths) FileUtils.mkpath(directory_path) end + log :yellow, "Starting download: #{sub_path}" if $verbose + unless (file = open(file_path, 'wb') rescue nil) log :red, "Unable to write file: #{sub_path.inspect}" @total_files_downloaded -= 1 @@ -205,7 +208,7 @@ def download_files(sub_paths) failed = proc do |http| error_code = http.response_header['X_AMZ_ERROR_CODE'] || http.response_header.status error_message = http.response_header['X_AMZ_ERROR_MESSAGE'] || "status: #{http.response_header.status}" - log :red, "Download failed: #{sub_path.inspect} (#{error_message})" + log :red, "Download failed: #{sub_path.inspect} (encoding: #{sub_path.encoding}, #{error_message})" @downloading_file_count -= 1 file.close if error_code != 'IncorrectEndpoint' && error_code != 400 && error_code != 404 @@ -401,7 +404,7 @@ def check_files def schedule_next_update if $last_client_update_check_at - if Time.now - $last_client_update_check_at >= 1.minutes + if Time.now - $last_client_update_check_at >= 30.minutes update_sync_client_if_needed do schedule_next_update end