Commit 1130d381 authored by Julien Muchembled's avatar Julien Muchembled

New tryDownload/tryUpload methods

parent 330e4eee
......@@ -286,6 +286,25 @@ class NetworkcacheClient(object):
connection.close()
raise HTTPError(url, r.status, r.reason, r.msg, r.fp)
def tryDownload(self, key):
"""
To be called before attemting to download from network cache.
bool(returned value) is True if that possible (i.e. configured),
- in which case the method logs what's going to happen;
- else the caller should continue without network cache.
"""
config_get = self.config.get
if config_get('download-dir-url') and config_get('download-cache-url'):
logger.info('Trying to download %s from network cache...', key)
return True
def tryUpload(self, key):
"""Similar to tryDownload but for upload"""
config_get = self.config.get
if config_get('upload-dir-url') and config_get('upload-cache-url'):
logger.info('Trying to upload %s to network cache...', key)
return True
@staticmethod
def archive(path):
# Don't create it to /tmp dir as it can be too small.
......
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