Permalink
Browse files

get first task id as get 404 error when fetch files

  • Loading branch information...
1 parent 646624c commit 9fffacb5065a93c04131fe3361d5772389e7e291 Binux committed Jan 17, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 libs/db_task_manager.py
View
@@ -102,7 +102,7 @@ def _update_task_list(self, limit=10, st=0, ignore=False):
session = Session()
tasks = self.xunlei.get_task_list(limit, st)
for task in tasks[::-1]:
- if task['lixian_url']:
+ if not self.last_task_id and task['lixian_url']:
self.last_task_id = task['task_id']
db_task_status = session.query(db.Task.status).filter(
db.Task.id == task['task_id']).first()
@@ -157,7 +157,7 @@ def _update_file_list(self, task):
return False
for file in files:
- if file['lixian_url']:
+ if not self.last_task_id and file['lixian_url']:
self.last_task_id = file['task_id']
db_file = db.File()
db_file.id = file['task_id']
@@ -252,7 +252,7 @@ def get_file_list(self, task_id):
#fix lixian url
if not self.last_task_id:
- raise Exception, "add a task and refresh task list first!"
+ return []
for file in task.files:
file.lixian_url = file._lixian_url % {"uid": self.uid, "tid": self.last_task_id}
return task.files

0 comments on commit 9fffacb

Please sign in to comment.