Cancellation
Cancel a running transfer from another process by calling cancel() with the identifier you passed to id():
use Pullr\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.
Binding a canceller
The package ships NullCancellationStore, which never cancels. Bind your own implementation so cancel signals survive across processes (Redis, database, cache, …).
use Pullr\LaravelAria2\Contracts\CancellationStore;use Pullr\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.
Contract
namespace Pullr\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 (signal, isSignaled, storeGid, gid, clearRuntimeState, clear). Canceller adds aliases that host applications typically expose.