Method: Chef::Provider::ZipFile#action_zip

Defined in:
lib/garcon/chef/provider/zip_file.rb

#action_zipObject



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/garcon/chef/provider/zip_file.rb', line 122

def action_zip
  if ::File.exists?(r.path) && !r.overwrite
    Chef::Log.info "#{r.path} already exists - nothing to do"
  else
    ::File.unlink(r.path) if ::File.exists?(r.path)
    if ::File.directory?(r.source)
      converge_by "Zip #{r.source}" do
        z = Zip::File.new(r.path, true)
        Find.find(r.source) do |f|
          next if f == r.source
          zip_fname = f.sub(r.source, '')
          z.add(zip_fname, f)
        end
        z.close
        do_acl_changes
        r.updated_by_last_action(true)
      end
    else
      Chef::Log.warn 'A valid directory must be specified for ziping.'
    end
  end
end