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.



49
50
51
52
53
54
55
56
57
58
# File 'lib/aspera/cli/transfer_actions.rb', line 49

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.



40
41
42
43
# File 'lib/aspera/cli/transfer_actions.rb', line 40

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:

  • UUID returned at submission time



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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}" }
  # Inject the in-process agent reference (direct/httpgw) if still alive in this process.
  ref = store.agent_ref(job_id)
  entry['agent_params']['_agent_ref'] = ref if ref
  live = query_live_status(entry)
  if live
    entry.merge!(live)
    store.write(job_id, entry)
  end
  Result::SingleObject.new(entry)
end