From e89eb6e3e08d6796ee08c73380c6ff9027a20ef5 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 6 Dec 2018 10:05:35 -0500 Subject: [PATCH] Fixes #9 --- app.py | 5 +++-- database.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 32fc56c..dae9c1a 100644 --- a/app.py +++ b/app.py @@ -542,9 +542,10 @@ def admin_crawl_logs(): def api_get_task(): token = request.form.get("token") name = db.check_api_token(token) + accept_ftp = request.form.get("accept") == "ftp" if "accept" in request.form else False if name: - task = db.pop_task(name, False) + task = db.pop_task(name, accept_ftp) logger.debug("API get task from " + name) if task: @@ -558,7 +559,7 @@ def api_get_task(): task = Task(website_id, website.url) db.put_task(task) - task = db.pop_task(name, False) + task = db.pop_task(name, accept_ftp) except: logger.error("Couldn't create new task") abort(404) diff --git a/database.py b/database.py index 295110b..f3b7f2a 100644 --- a/database.py +++ b/database.py @@ -388,7 +388,7 @@ class Database: cursor.execute("SELECT id, website_id, url, priority, callback_type, callback_args " + "FROM Queue WHERE assigned_crawler is NULL " + - ("AND url LIKE 'ftp%' " if ftp else "") + + ("AND url LIKE 'ftp%' " if ftp else "AND url LIKE 'http%' ") + "ORDER BY priority DESC, Queue.id " + "ASC LIMIT 1") task = cursor.fetchone()