lib/s3_website/uploader.rb in s3_website-1.0.3 vs lib/s3_website/uploader.rb in s3_website-1.1.0

- old
+ new

@@ -16,15 +16,21 @@ ) redirects = config['redirects'] || {} changed_redirects = setup_redirects redirects, config, s3 - deleted_files_count = remove_superfluous_files(s3, { :s3_bucket => config['s3_bucket'], - :site_dir => site_dir, - :redirects => redirects, - :in_headless_mode => in_headless_mode, - :ignore_on_server => config["ignore_on_server"] }) + deleted_files_count = remove_superfluous_files( + s3, + config, + { + :s3_bucket => config['s3_bucket'], + :site_dir => site_dir, + :redirects => redirects, + :in_headless_mode => in_headless_mode, + :ignore_on_server => config["ignore_on_server"] + } + ) print_done_report config [new_files_count, changed_files_count, deleted_files_count, changed_files, changed_redirects] end @@ -39,11 +45,14 @@ puts "Done! Go visit: http://#{website_hostname_with_bucket}/index.html" end def self.upload_files(s3, config, site_dir) changed_files, new_files = DiffHelper.resolve_files_to_upload( - s3.buckets[config['s3_bucket']], site_dir) + s3.buckets[config['s3_bucket']], + site_dir, + config + ) to_upload = (changed_files + new_files).reject { |f| Upload.is_blacklisted f } if to_upload.empty? puts "No new or changed files to upload" else pre_upload_report = [] @@ -57,11 +66,11 @@ end [new_files.length, changed_files.length, changed_files] end def self.upload_in_parallel_or_sequentially(files_to_upload, s3, config, site_dir) - Parallelism.each_in_parallel_or_sequentially(files_to_upload) { |f| + Parallelism.each_in_parallel_or_sequentially(files_to_upload, config) { |f| upload_file(f, s3, config, site_dir) } end def self.upload_file(file, s3, config, site_dir) @@ -112,11 +121,11 @@ else :no_redirect_operation_performed end end - def self.remove_superfluous_files(s3, options) + def self.remove_superfluous_files(s3, config, options) s3_bucket_name = options.fetch(:s3_bucket) site_dir = options.fetch(:site_dir) in_headless_mode = options.fetch(:in_headless_mode) remote_files = s3.buckets[s3_bucket_name].objects.map { |f| f.key } @@ -128,10 +137,10 @@ files_to_delete.each { |s3_object_key| delete_s3_object s3, s3_bucket_name, s3_object_key deleted_files_count += 1 } else - Keyboard.if_user_confirms_delete(files_to_delete) { |s3_object_key| + Keyboard.if_user_confirms_delete(files_to_delete, config) { |s3_object_key| delete_s3_object s3, s3_bucket_name, s3_object_key deleted_files_count += 1 } end deleted_files_count