Cancellation
Cancel a running transfer from another process by calling cancel() with the identifier you passed to id():
use Dasundev\LaravelAria2\Facades\Aria2; Aria2::cancel($pull->id);
The downloader polls a Canceller between tellStatus calls. When it sees the signal it force-removes the GID and throws TransferCancelledException. TransferCancelled and TransferFailed are both dispatched.
The package ships NullCancellationStore, which never cancels. Bind your own implementation so cancel signals survive across processes.
use Dasundev\LaravelAria2\Contracts\CancellationStore;use Dasundev\LaravelAria2\Contracts\Canceller; $this->app->singleton(CancellationStore::class, RedisCancellationStore::class);$this->app->alias(CancellationStore::class, Canceller::class);
If the bound CancellationStore also implements Canceller, the service provider reuses it. Otherwise it falls back to NullCancellationStore for Canceller.
namespace Dasundev\LaravelAria2\Contracts; interface Canceller extends CancellationStore{ public function cancel(int|string $transferId): void; public function cancelled(int|string $transferId): bool; public function rememberGid(int|string $transferId, string $gid): void; public function forget(int|string $transferId): void;}
CancellationStore is the smaller surface the downloader uses. Canceller adds aliases that host applications typically expose.