mirror of
https://github.com/simon987/od-database.git
synced 2025-04-19 18:36:44 +00:00
Fixes #9
This commit is contained in:
parent
d4fd764536
commit
e89eb6e3e0
5
app.py
5
app.py
@ -542,9 +542,10 @@ def admin_crawl_logs():
|
|||||||
def api_get_task():
|
def api_get_task():
|
||||||
token = request.form.get("token")
|
token = request.form.get("token")
|
||||||
name = db.check_api_token(token)
|
name = db.check_api_token(token)
|
||||||
|
accept_ftp = request.form.get("accept") == "ftp" if "accept" in request.form else False
|
||||||
|
|
||||||
if name:
|
if name:
|
||||||
task = db.pop_task(name, False)
|
task = db.pop_task(name, accept_ftp)
|
||||||
logger.debug("API get task from " + name)
|
logger.debug("API get task from " + name)
|
||||||
|
|
||||||
if task:
|
if task:
|
||||||
@ -558,7 +559,7 @@ def api_get_task():
|
|||||||
task = Task(website_id, website.url)
|
task = Task(website_id, website.url)
|
||||||
db.put_task(task)
|
db.put_task(task)
|
||||||
|
|
||||||
task = db.pop_task(name, False)
|
task = db.pop_task(name, accept_ftp)
|
||||||
except:
|
except:
|
||||||
logger.error("Couldn't create new task")
|
logger.error("Couldn't create new task")
|
||||||
abort(404)
|
abort(404)
|
||||||
|
@ -388,7 +388,7 @@ class Database:
|
|||||||
|
|
||||||
cursor.execute("SELECT id, website_id, url, priority, callback_type, callback_args " +
|
cursor.execute("SELECT id, website_id, url, priority, callback_type, callback_args " +
|
||||||
"FROM Queue WHERE assigned_crawler is NULL " +
|
"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 " +
|
"ORDER BY priority DESC, Queue.id " +
|
||||||
"ASC LIMIT 1")
|
"ASC LIMIT 1")
|
||||||
task = cursor.fetchone()
|
task = cursor.fetchone()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user