Commit efd4a76d authored by Łukasz Nowak's avatar Łukasz Nowak

Minimise memory footprint during download.

There is no need to read and store downloaded file. Returning the location is
good enough.
parent d629e039
0.2 (unreleased)
================
* Incompatible change: NetworkcacheClient.download returns downloaded
location instead of content in order to minimise memory footprint. [Łukasz
Nowak]
* Minimise memory footprint during upload. [Łukasz Nowak]
* Use PUT instead of POST during upload. [Lucas Carvalho]
......
......@@ -18,7 +18,6 @@ import hashlib
import httplib
import json
import os
import tempfile
from urllib import urlretrieve
from urlparse import urlparse
......@@ -130,16 +129,11 @@ class NetworkcacheClient(object):
def download(self, sha512sum):
''' Download the file.
It uses http GET request method.
Returns downloaded file absolute location
'''
sha_cache_url = os.path.join(self.shacache_url, sha512sum)
path, headers = urlretrieve(sha_cache_url, tempfile.mktemp())
f = open(path)
try:
file_content = f.read()
finally:
f.close()
return file_content
path, headers = urlretrieve(sha_cache_url)
return path
def select(self, directory_key=None):
''' Download a file from shacache by selecting the entry in shadir
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment