Skip to content
Myr

Update release script to upload assets in parallel

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent c4baa6a · Browse files · 1 file+18 added−16 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+18 added−16 removed

  • other:+18 added−16 removed

1 file+18 added−16 removed

modified:src/update_assets.rb+18 added-16 removed
21 unmodified lines
2223# List assets24assets = Hash[rel['assets'].map { |a| a.values_at *%w[name id] }]2526files.select { |f| File.exists? f }.each do |file|27 name = File.basename file26files.select { |f| File.exists? f }.map do |file|27 Thread.new do28 name = File.basename file2929 if asset_id = assets[name]30 puts "#{name} found. Deleting asset id #{asset_id}."31 RestClient.delete "#{base}/assets/#{asset_id}",32 :authorization => "token #{token}"33 else34 puts "#{name} not found"35 end30 if asset_id = assets[name]31 puts "#{name} found. Deleting asset id #{asset_id}."32 RestClient.delete "#{base}/assets/#{asset_id}",33 :authorization => "token #{token}"34 else35 puts "#{name} not found"36 end3737 puts "Uploading #{name}"38 RestClient.post(39 "#{base.sub 'api', 'uploads'}/#{rel['id']}/assets?name=#{name}",40 File.read(file),41 :authorization => "token #{token}",42 :content_type => "application/octet-stream")43end38 puts "Uploading #{name}"39 RestClient.post(40 "#{base.sub 'api', 'uploads'}/#{rel['id']}/assets?name=#{name}",41 File.read(file),42 :authorization => "token #{token}",43 :content_type => "application/octet-stream")44 end45end.each(&:join)