Skip to content

Improve cancellation #62

Open
Open
@DmitriyYukhanov

Description

@DmitriyYukhanov

Hey,

This one is related to #32, and I'm going to expand it a bit to a more detailed request.

It's currently not possible to cancel the download if something goes wrong and CDN does return errors making inner code throw.

But in catches, the IsCanceled flag is not checked, and it keeps trying again even if download was cancelled.

Adding if (IsCanceled) ... check before calling DownloadData.Create() could help too.

Also looks like DownloadData can't cancel and will make 3 attempts regardless.

Ideally, UpdatingContext.Runner should have a Cancel() method to cancel all internal downloaders in a currently executing step and skip not yet run steps (i.e. if it was cancelled while running Repairer, the following Updater won't even start).

Cleaning temporary data would be a great option on the top of this as well, but I believe it may deserve a dedicated feature request ticket.

Speaking of the cancellation itself, it would be great to introduce proper cancellation support through the CancellationToken while using either HttpClient async methods (it's not compatible with old Unity versions) or use IAsyncResult from the HttpWebRequest.BeginGetResponse() and similar in order to be able to immediately cancel operations.

Alternatively, cancellation could just terminate long-running tasks for the downloads.

The goal is to have 1 single API which can tell the context internals: "That's it! Let's cancel everything we do" and would immediately cancel anything happening under the hood =D

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions