Sha256: 19bb4a3a679a73fae6f33c2ae4f520d71bda0be4ae78b475ce7aa5f295ee980e

Contents?: true

Size: 838 Bytes

Versions: 2

Compression:

Stored size: 838 Bytes

Contents

module VpsAdmin::CLI::Commands
  class BaseDownload < HaveAPI::CLI::Command
    def initialize(*)
      super

      @api.set_opts(block: false)
    end

    protected

    def find_or_create_dl(opts, do_create = true)
      @api.snapshot_download.index(snapshot: opts[:snapshot]).each do |r|
        next unless opts[:from_snapshot] == (r.from_snapshot && r.from_snapshot_id)
        if r.format != opts[:format].to_s
          raise "SnapshotDownload id=#{r.id} is in unusable format '#{r.format}' (needs '#{opts[:format]}')"
        end

        return [r, false]
      end

      if do_create
        [@api.snapshot_download.create(opts), true]

      else
        [nil, true]
      end
    end

    def msg(str)
      puts str unless @opts[:quiet]
    end

    def warn_msg(str)
      warn str unless @opts[:quiet]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vpsadmin-client-4.0.0 lib/vpsadmin/cli/commands/base_download.rb
vpsadmin-client-3.0.0.master.20240728.pre.0.dc5474cc lib/vpsadmin/cli/commands/base_download.rb