RedditDownloader icon indicating copy to clipboard operation
RedditDownloader copied to clipboard

Add ability to stop downloads in progress

Open B13rg opened this issue 3 years ago • 2 comments

Related to issue #90 and #94

This set of changes allows the user to stop downloads in progress. When downloading is started, the start button becomes a stop button instead of becoming disabled.

When pressed, the stop button closes the download queue, then joins the running downloader threads, before stopping the loader thread as well. When the loader is terminated, it should also stop the deduplicator thread, which we may or may not want to happen.

As long as the deduplicator thread isn't double started, I think it should continue to run in the background instead of being canceled.

B13rg avatar Apr 03 '22 23:04 B13rg

This is looking good. Thanks for the addition.

It's been quite a while since I worked on the Python version of RMD but since this is using preexisting mechanisms it looks like this should work gracefully, albeit after waiting for any long-running downloads to complete. Even if RMD won't always be able to instantly stop when requested, it seems reasonable to me to expose this functionality to the user.

shadowmoose avatar Apr 06 '22 22:04 shadowmoose

I ended up adding a timeout. When there's a long-running download like a youtube video, the ui will freeze and timeout. While it's waiting for the thread to join, it hits the page timeout here: https://github.com/shadowmoose/RedditDownloader/blob/3e4b4ef52be56e50bf3561081fe3257575de0fed/redditdownloader/web/js/App.js#L24

I opted to add a 2 second timeout. My goal is to allow quicker downloads like images and texts post to finish, but not stop everything for larger youtube videos that may continue on for minutes.

Worst case, it will stall num_downloader_threads * 2 seconds, but that's if everything is a long-running download that doesn't finish in time.

Since the database entry for a download is updated once it's completely downloaded, the media should continue being downloaded from scratch next time downloading is started.

B13rg avatar Apr 10 '22 06:04 B13rg

Is this working now ?

ghost avatar Oct 17 '22 06:10 ghost

Thanks for the PR, and for making the changes. Looks great!

shadowmoose avatar Apr 06 '23 01:04 shadowmoose