This commit is contained in:
Simon 2018-12-06 10:05:35 -05:00
parent d4fd764536
commit e89eb6e3e0
2 changed files with 4 additions and 3 deletions

5
app.py
View File

@ -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)

View File

@ -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()