Class: ShopifyCLI::Theme::Syncer::Uploader

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
JsonDeleteHandler, JsonUpdateHandler
Defined in:
lib/shopify_cli/theme/syncer/uploader.rb,
lib/shopify_cli/theme/syncer/uploader/bulk.rb,
lib/shopify_cli/theme/syncer/uploader/bulk_job.rb,
lib/shopify_cli/theme/syncer/uploader/bulk_item.rb,
lib/shopify_cli/theme/syncer/uploader/bulk_request.rb,
lib/shopify_cli/theme/syncer/uploader/forms/apply_to_all.rb,
lib/shopify_cli/theme/syncer/uploader/json_delete_handler.rb,
lib/shopify_cli/theme/syncer/uploader/json_update_handler.rb,
lib/shopify_cli/theme/syncer/uploader/forms/apply_to_all_form.rb,
lib/shopify_cli/theme/syncer/uploader/forms/base_strategy_form.rb,
lib/shopify_cli/theme/syncer/uploader/forms/select_delete_strategy.rb,
lib/shopify_cli/theme/syncer/uploader/forms/select_update_strategy.rb

Defined Under Namespace

Modules: Forms, JsonDeleteHandler, JsonUpdateHandler Classes: Bulk, BulkItem, BulkJob, BulkRequest

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from JsonUpdateHandler

#enqueue_json_updates

Methods included from JsonDeleteHandler

#enqueue_json_deletes

Constructor Details

#initialize(syncer, delete, delay_low_priority_files, &update_progress_bar_block) ⇒ Uploader

Returns a new instance of Uploader.



40
41
42
43
44
45
46
# File 'lib/shopify_cli/theme/syncer/uploader.rb', line 40

def initialize(syncer, delete, delay_low_priority_files, &update_progress_bar_block)
  @syncer = syncer
  @delete = delete
  @delay_low_priority_files = delay_low_priority_files
  @update_progress_bar_block = update_progress_bar_block
  @progress_bar_mutex = Mutex.new
end

Instance Attribute Details

#syncerObject (readonly)

Returns the value of attribute syncer.



19
20
21
# File 'lib/shopify_cli/theme/syncer/uploader.rb', line 19

def syncer
  @syncer
end

Instance Method Details

#delete_files!Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/shopify_cli/theme/syncer/uploader.rb', line 59

def delete_files!
  return unless delete?

  files_present_remotely = checksums.keys
  files_present_locally = theme.theme_files.map(&:relative_path)

  json_files, other_files = (files_present_remotely - files_present_locally)
    .map { |file| theme[file] }
    .reject { |file| ignore_file?(file) }
    .partition(&:json?)

  enqueue_deletes(other_files)
  enqueue_json_deletes(json_files)
end

#upload!Object



48
49
50
51
52
53
54
55
56
57
# File 'lib/shopify_cli/theme/syncer/uploader.rb', line 48

def upload!
  fetch_checksums!
  delete_files!

  if bulk_updates_activated? && overwrite_json?
    bulk_upload!
  else
    async_upload!
  end
end