Method: Octopress::Deploy::S3#write_files

Defined in:
lib/octopress-deploy/s3.rb

#write_filesObject

Write site files to the selected bucket



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/octopress-deploy/s3.rb', line 80

def write_files
  puts "Writing #{pluralize('file', site_files.size)}:" if @verbose
  files_to_invalidate = []
  site_files.each do |file|
    s3_filename = remote_path(file)
    o = @bucket.objects[s3_filename]
    file_with_options = (file, s3_filename);

    begin
      s3sum = o.etag.tr('"','') if o.exists?
    rescue AWS::S3::Errors::NoSuchKey
      s3sum = ""
    end

    if @incremental && (s3sum == Digest::MD5.file(file).hexdigest)
      if @verbose
        puts "= #{remote_path(file)}"
      else
        progress('=')
      end
    else 
      o.write(file_with_options)
      files_to_invalidate.push(file)
      if @verbose
        puts "+ #{remote_path(file)}"
      else
        progress('+')
      end
    end
  end

  invalidate_cache(files_to_invalidate) unless @distro_id.nil?
end