From 5e01cc38fec3209ff3f8179b69084d14b6a1f9a0 Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Tue, 4 Aug 2020 11:36:36 +0000 Subject: [PATCH] Fix downloaders --- src/mangadex/downloader.cr | 16 +++++++++------- src/plugin/downloader.cr | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/mangadex/downloader.cr b/src/mangadex/downloader.cr index f335af2..793763d 100644 --- a/src/mangadex/downloader.cr +++ b/src/mangadex/downloader.cr @@ -27,14 +27,16 @@ module MangaDex def pop : Queue::Job? job = nil - DB.open "sqlite3://#{@queue.path}" do |db| - begin - db.query_one "select * from queue where id not like '%-%' " \ - "and (status = 0 or status = 1) " \ - "order by time limit 1" do |res| - job = Queue::Job.from_query_result res + MainFiber.run do + DB.open "sqlite3://#{@queue.path}" do |db| + begin + db.query_one "select * from queue where id not like '%-%' " \ + "and (status = 0 or status = 1) " \ + "order by time limit 1" do |res| + job = Queue::Job.from_query_result res + end + rescue end - rescue end end job diff --git a/src/plugin/downloader.cr b/src/plugin/downloader.cr index 4c23432..31d066d 100644 --- a/src/plugin/downloader.cr +++ b/src/plugin/downloader.cr @@ -8,14 +8,16 @@ class Plugin def pop : Queue::Job? job = nil - DB.open "sqlite3://#{@queue.path}" do |db| - begin - db.query_one "select * from queue where id like '%-%' " \ - "and (status = 0 or status = 1) " \ - "order by time limit 1" do |res| - job = Queue::Job.from_query_result res + MainFiber.run do + DB.open "sqlite3://#{@queue.path}" do |db| + begin + db.query_one "select * from queue where id like '%-%' " \ + "and (status = 0 or status = 1) " \ + "order by time limit 1" do |res| + job = Queue::Job.from_query_result res + end + rescue end - rescue end end job