Suspend/Resume/Kill for knewstuff file jobs.
Open, WishlistPublic

Description

I told @leinir I'd look into this.

So far I can tell the following is needed.

KJob has suspend, resume and kill functions. These call doSuspend, doResume and doKill, which need to be implemented by the classes that extend KJob.

Within KNewStuff, we have download and copy jobs.

For copy jobs, we will need to handle suspend/resume/kill in FileCopyWorker::run(), and then have the virtual overides in FileCopyJob. The source object in FileCopyWorker is a QIODevice, so we can tell it to either skip or seek to the appropriate point when resuming.

For download jobs, the suspend/resume/kill needs be handled in HTTPWorker::handleReadyRead(). Here the object is a QNetworkReply, which is also a QIODevice, but if we're gonna handle a resume, we'll need to use skip(), as sequential QIODevices like QNetworkReply don't handle seek.
The virtual overrides here need to go into both HTTPJob and DownloadJob.

It'll take a bit of puzzling to get the functions working, but I think it should be possible. I am not sure how to connect this to the gui though, and given the fact we don't have a progress bar yet, I am pretty sure noone else really knows either? :D

woltherav created this task.Oct 5 2019, 4:48 PM
woltherav triaged this task as Wishlist priority.
woltherav added a comment.EditedOct 6 2019, 12:40 PM

Because I am unsure if you can interrupt a loop in a different function, I tried to figure out what KIO does. KIO seems to have a tiny jungle of jobs calling subjobs telling workers to suspend, and eventually the whole thing ends up at ConnectionBackend, which seems (TCP) Socket based. (With a local and remote modes, much like our download jobs).

I suspect the best course of action is to rewrite the worked to be socket based if we want simple suspend/resume. But I am pretty terrible with protocol stuff, so I don't know if this is a good idea generally, or only a good idea for the big files download and that stuff like preview jobs and whatever else uses the httpworker shouldn't be done on sockets.

EDIT: Yeah, KIO's socket stuff seems to be for things like nextcloud support. So I am not sure if this would be a good idea at all...