Pass file info for addTask call
This commit is contained in:
parent
f45c0b2377
commit
c91011e6ea
2 changed files with 5 additions and 4 deletions
|
@ -760,11 +760,11 @@ class Site(object):
|
||||||
self.log.debug("%s: Download not allowed" % inner_path)
|
self.log.debug("%s: Download not allowed" % inner_path)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
task = self.worker_manager.addTask(inner_path, peer, priority=priority)
|
task = self.worker_manager.addTask(inner_path, peer, priority=priority, file_info=file_info)
|
||||||
if blocking:
|
if blocking:
|
||||||
return task["evt"].get()
|
return task["evt"].get()
|
||||||
else:
|
else:
|
||||||
return task
|
return task["evt"]
|
||||||
|
|
||||||
# Add or update a peer to site
|
# Add or update a peer to site
|
||||||
# return_peer: Always return the peer even if it was already present
|
# return_peer: Always return the peer even if it was already present
|
||||||
|
|
|
@ -409,7 +409,7 @@ class WorkerManager(object):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
# Create new task and return asyncresult
|
# Create new task and return asyncresult
|
||||||
def addTask(self, inner_path, peer=None, priority=0):
|
def addTask(self, inner_path, peer=None, priority=0, file_info=None):
|
||||||
self.site.onFileStart(inner_path) # First task, trigger site download started
|
self.site.onFileStart(inner_path) # First task, trigger site download started
|
||||||
task = self.findTask(inner_path)
|
task = self.findTask(inner_path)
|
||||||
if task: # Already has task for that file
|
if task: # Already has task for that file
|
||||||
|
@ -431,6 +431,7 @@ class WorkerManager(object):
|
||||||
peers = [peer] # Only download from this peer
|
peers = [peer] # Only download from this peer
|
||||||
else:
|
else:
|
||||||
peers = None
|
peers = None
|
||||||
|
if not file_info:
|
||||||
file_info = self.site.content_manager.getFileInfo(inner_path)
|
file_info = self.site.content_manager.getFileInfo(inner_path)
|
||||||
if file_info and file_info["optional"]:
|
if file_info and file_info["optional"]:
|
||||||
optional_hash_id = helper.toHashId(file_info["sha512"])
|
optional_hash_id = helper.toHashId(file_info["sha512"])
|
||||||
|
|
Loading…
Reference in a new issue