Cancel a download job when deleted from web UI

This commit is contained in:
Alex Ling
2020-12-12 16:15:16 +00:00
parent 1cd90926df
commit 9dcc9665ce
3 changed files with 34 additions and 0 deletions

View File

@@ -66,6 +66,8 @@ class Plugin
fail_count = 0
while page = plugin.next_page
break unless @queue.exists? job
fn = process_filename page["filename"].as_s
url = page["url"].as_s
headers = HTTP::Headers.new
@@ -109,6 +111,12 @@ class Plugin
end
end
unless @queue.exists? job
Logger.debug "Download cancelled"
@downloading = false
return
end
Logger.debug "Download completed. #{fail_count}/#{pages} failed"
writer.close
filename = File.join File.dirname(zip_path), File.basename(zip_path,