Skip to content

Commit

Permalink
corrected encoding for multiple platform compatibility
Browse files Browse the repository at this point in the history
corrected min time between sync client updates
  • Loading branch information
bawNg committed Sep 27, 2013
1 parent bd66bfd commit 706570f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
2 changes: 1 addition & 1 deletion ptsync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
require 'pp'
require './helpers'

PT_SYNC_VERSION = 0.9
PT_SYNC_VERSION = 1.0

$git_repo = File.directory?('./.git')

Expand Down
7 changes: 5 additions & 2 deletions sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Dir.chdir('../') if $packaged

#YAML::ENGINE.yamler = 'syck'
Encoding.default_external = 'utf-8'

initialize_config

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 706570f

Please sign in to comment.