Progress
Each time a field changes, the package emits a TransferStatus snapshot to your onProgress callback and dispatches TransferProgressed.
use Dasundev\LaravelAria2\Transfer\TransferStatus; Aria2::url($url) ->dir($directory) ->onProgress(function (TransferStatus $status) { $status->gid(); $status->status(); $status->percent(); $status->completedBytes(); $status->totalBytes(); $status->speed(); $status->displayName(); }) ->download();
Snapshots only contain fields that changed. A call may include gid without percent. Use has() when you need to distinguish missing from null:
if ($status->has('progress')) { $pull->progress = $status->percent();}
gid() and status() return strings when present. percent() is an integer from 0 to 100 and never goes backwards. completedBytes() and totalBytes() are integers. speed() is a formatted string such as 1.5MiB, 512KiB, or 42B. displayName() is the best name the package has found so far.
You can also call has($key), get($key), and toArray() on the snapshot.
Magnet and torrent metadata phases are withheld until the payload GID is active, so a 100% metadata fetch does not look like a finished download.
When a worker restarts mid-transfer, pass the last known values so the next snapshots stay consistent:
Aria2::url($pull->url) ->dir($pull->directory) ->id($pull->id) ->gid($pull->gid) ->previousProgress($pull->progress) ->previousSpeed($pull->speed) ->previousTotalBytes($pull->total_bytes) ->previousDisplayName($pull->display_name) ->download();