106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/wonko_the_sane/wonkoweb_uploader.rb', line 106
def upload_changes!
@changed_files.uniq!
return if Settings[:wonkoweb][:host].nil?
existing_uids = @benchmark.benchmark('initial index') { @client.index }[:index].map { |obj| obj[:uid] }
logger.info "Uploading #{@changed_files.size} changed files to WonkoWeb at #{Settings[:wonkoweb][:host]}..."
@changed_files.dup.each do |uid|
begin
@client.upload_file $rw.write_version_index Registry.instance.version_index uid
existing_uids << uid
@changed_files.delete uid
rescue => e
logger.error "Unable to upload file for #{uid} to WonkoWeb: #{e.message}"
logger.warn e.backtrace.first
binding.pry if $stdout.isatty && ENV['DEBUG_ON_ERROR']
end
end
logger.info 'Done.'
@benchmark.print_times true
num_versions = @changed_versions.collect { |k, v| v.size }.inject :+
logger.info "Uploading #{num_versions} changed versions to WonkoWeb at #{Settings[:wonkoweb][:host]}..."
@changed_versions.dup.each do |uid, versions|
versions.dup.each do |version|
begin
@client.upload_file $rw.write_version_index Registry.instance.version_index uid unless existing_uids.include? uid
@client.upload_version $rw.write_version Registry.instance.retrieve uid, version
versions.delete version
rescue => e
logger.error "Unable to upload version #{version} of #{uid} to WonkoWeb: #{e.message}"
logger.warn e.backtrace.first
binding.pry if $stdout.isatty && ENV['DEBUG_ON_ERROR']
end
@changed_versions.delete uid if versions.empty?
end
end
logger.info 'Done.'
@benchmark.print_times true
save_changes!
end
|