Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[#6]Generate md5 for upload based on entire zip, rather than just the…

… worker
  • Loading branch information...
commit 548f867042c771259ff67f4bed1efad9ce74c69e 1 parent be34a85
rkononov authored
Showing with 14 additions and 12 deletions.
  1. +14 −12 lib/iron_worker/service.rb
26 lib/iron_worker/service.rb
View
@@ -45,23 +45,25 @@ def upload(filename, class_name, options={})
existing_md5 = IO.read(md5_f)
end
- # Check for code changes.
- md5 = Digest::MD5.hexdigest(File.read(filename))
- new_code = false
- if self.config.force_upload || md5 != existing_md5
- IronWorker.logger.info "Uploading #{class_name}, code modified."
- File.open(md5_f, 'w') { |f| f.write(md5) }
- new_code = true
- # todo: delete md5 file if error occurs during upload process
- else
-# puts "#{class_name}: same code, not uploading"
- return
- end
begin
zip_filename = build_merged_file(filename, options[:merge], options[:unmerge], options[:merged_gems], options[:merged_mailers], options[:merged_folders])
+ # Check for code changes.
+ zipfile = Zip::ZipFile.open(zip_filename, Zip::ZipFile::CREATE)
+ crc = zipfile.entries.collect{|x|x.crc}.inject(:+)
+ new_code = false
+ if self.config.force_upload || crc.to_s != existing_md5
+ IronWorker.logger.info "Uploading #{class_name}, code modified."
+ File.open(md5_f, 'w') { |f| f.write(crc) }
+ new_code = true
+ # todo: delete md5 file if error occurs during upload process
+ else
+# puts "#{class_name}: same code, not uploading"
+ return
+ end
+
if new_code
upload_code(name, zip_filename, 'runner.rb', :runtime=>'ruby')
end

4 comments on commit 548f867

Travis Reeder
Owner

Roman, will this run build_merged_file every time someone queues up a job?

Roman
Collaborator

yes, because anyway we need to scan every file he is trying to queue for changes

Travis Reeder
Owner

Do we still have the is_uploaded? check so it only does this once per ruby process? Otherwise, that would add a huge overhead, imagine running that 10,000 times in a row.

Roman
Collaborator

we're doing this once on first queue

look in base.rb

we're checking

if !uploaded?

and setting after upload

self.class.instance_variable_set(:@uploaded, true)

Please sign in to comment.
Something went wrong with that request. Please try again.