Module: Aspera::Cli::TransferActions

Included in:
Plugins::Config
Defined in:
lib/aspera/cli/transfer_actions.rb

Overview

Mixin for Config plugin: async transfer management actions. Exposes three sub-commands under config transfer:

status  --id=<job_id>   Re-query a running/completed transfer
list                    List all persisted async transfer entries
cleanup                 Remove completed/failed/cancelled entries

Architecture:

- remote-daemon agents (desktop, node, connect, transferd): transfer_id + agent_params
are persisted in AsyncTransferStore; status is re-queried via Agent::Xxx.transfer_status
- direct agent: transfers live in Ruby threads - store is the agent's @sessions;
status is not persistable across process restarts (returns an informational message)

Instance Method Summary collapse

Instance Method Details

#action_transfer_cleanupObject

Delete completed, failed, and cancelled entries from the store.



46
47
48
49
50
51
52
53
54
55
# File 'lib/aspera/cli/transfer_actions.rb', line 46

def action_transfer_cleanup(**)
  store = async_transfer_store
  deleted = store.list
    .select{ |e| TERMINAL_STATUSES.include?(e['status'])}
    .map do |e|
    store.delete(e['job_id'])
    e['job_id']
  end
  Result::Status.new("Deleted #{deleted.size} completed transfer(s)#{": #{deleted.join(', ')}" unless deleted.empty?}")
end

#action_transfer_listObject

List all persisted async transfer entries.



37
38
39
40
# File 'lib/aspera/cli/transfer_actions.rb', line 37

def action_transfer_list(**)
  rows = async_transfer_store.list
  Result::ObjectList.new(rows, fields: %w[job_id agent_type status started_at ended_at bytes_transferred transfer_id])
end

#action_transfer_status(job_id:) ⇒ Object

Re-query the status of a single async transfer job.

Parameters:

  • job_id (String)

    UUID returned at submission time



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/aspera/cli/transfer_actions.rb', line 24

def action_transfer_status(job_id:, **)
  store = async_transfer_store
  entry = store.read(job_id)
  Aspera.assert(!entry.nil?, type: Cli::BadArgument){"Unknown job_id: #{job_id}"}
  live = query_live_status(entry)
  if live
    entry.merge!(live)
    store.write(job_id, entry)
  end
  Result::SingleObject.new(entry)
end