Skip to content
This repository has been archived by the owner on May 16, 2019. It is now read-only.

Commit

Permalink
Only fetch image from connected peer
Browse files Browse the repository at this point in the history
  • Loading branch information
cpacia committed Mar 10, 2016
1 parent ba310b8 commit c421102
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions api/restapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,14 @@ def _setContentDispositionAndSend(file_path, extension, content_type):
else:
image_path = DATA_FOLDER + "cache/" + request.args["hash"][0]
if not os.path.exists(image_path) and "guid" in request.args:
def get_node(node):
if node is not None:
node = None
for connection in self.protocol.values():
if connection.handler.node is not None and \
connection.handler.node.id == unhexlify(request.args["guid"][0]):
node = connection.handler.node
self.mserver.get_image(node, unhexlify(request.args["hash"][0])).addCallback(_showImage)
else:
_showImage()
self.kserver.resolve(unhexlify(request.args["guid"][0])).addCallback(get_node)
if node is None:
_showImage()
else:
_showImage()
else:
Expand Down

0 comments on commit c421102

Please sign in to comment.