Skip to content

Commit

Permalink
rename completed files
Browse files Browse the repository at this point in the history
  • Loading branch information
clowwindy authored and clowwindy committed Dec 2, 2011
1 parent e9c9c8a commit 79539bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions core/controller.py
Expand Up @@ -334,6 +334,12 @@ def _oncomplete(self, a_task):
db.update('Task', where="id = %d" % a_task.id, date_completed = "%d" % time.time(),completed_size = "%d" % a_task.completed_size, total_size = "%d" % a_task.total_size, filename=a_task.filename)
log("complete: "+a_task.url)
self._close_db(db)
# rename filename
self.filename_lock.acquire()
try:
os.rename(a_task.partfilename, os.path.join(self.settings.download_path, a_task.filename))
finally:
self.filename_lock.release()
self.update_event.set()

def _get_filename_by_url(self, url):
Expand Down
4 changes: 2 additions & 2 deletions webui/app.py
Expand Up @@ -46,8 +46,8 @@ def POST(self):
web.header('Content-Type', 'application/json')
try:
data = json.loads(web.data())
#TODO: 支持多个URL
controller.add_tasks(data['urls'].splitlines(), data['cookie'], data['referer'])
# remove empty lines, add tasks
controller.add_tasks(filter(None, data['urls'].splitlines()), data['cookie'], data['referer'])
return '"OK"'
except Exception, e:
return json.dumps(unicode(e))
Expand Down

0 comments on commit 79539bd

Please sign in to comment.