Sha256: 4655d2df6bdb1dc2c462cfeb19fb4d02456a0cd7336396aaffff94e9ca1f0c49

Contents?: true

Size: 816 Bytes

Versions: 2

Compression:

Stored size: 816 Bytes

Contents

module TerraspacePluginGoogle::Interfaces
  class Summary
    include Terraspace::Plugin::Summary::Interface
    include TerraspacePluginGoogle::Clients

    # interface method
    def key_field
      'prefix'
    end

    # interface method
    def download
      bucket = storage.bucket(@bucket)
      bucket.files(prefix: @folder).all do |f|
        file = bucket.file(f.name)
        next if file.nil? # in case file has been removed since .files
        # Note the f.name already includes the folder
        local_path = "#{@dest}/#{f.name}"
        FileUtils.mkdir_p(File.dirname(local_path))
        file.download(local_path)
      end
    end

    # interface method
    def delete_empty_statefile(key)
      bucket = storage.bucket(@bucket)
      file = bucket.file(key)
      file.delete
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
terraspace_plugin_google-0.2.0 lib/terraspace_plugin_google/interfaces/summary.rb
terraspace_plugin_google-0.1.1 lib/terraspace_plugin_google/interfaces/summary.rb