def handle_download_request(file_name): mgr = CacheFileManager(file_name) try: if not mgr.is_available: mgr.cache_async() return flask.redirect(mgr.source_url, 302) return flask.redirect(mgr.local_download_url) except Exception as x: print("Cache-Tier: Error handling download request (falling back to source): ".format(repr(x))) return flask.redirect(mgr.source_url, 302)
def handle_download_request(file_name): mgr = CacheFileManager(file_name) try: if not mgr.is_available: mgr.cache_async() return flask.redirect(mgr.source_url, 302) return flask.redirect(mgr.local_download_url) except Exception as x: print( "Cache-Tier: Error handling download request (falling back to source): " .format(repr(x))) return flask.redirect(mgr.source_url, 302)
def handle_verify_request(file_name): try: mgr = CacheFileManager(file_name) if not mgr.is_available: mgr.cache_async() return flask.json.jsonify(available=mgr.is_available, file=file_name, error=False, error_msg=None) except Exception as x: print("Cache-Tier: Error verifying request: ".format(repr(x))) return flask.json.jsonify(available=False, file=file_name, error=True, error_msg=str(x))
def handle_verify_request(file_name): try: mgr = CacheFileManager(file_name) if not mgr.is_available: mgr.cache_async() return flask.json.jsonify( available=mgr.is_available, file=file_name, error=False, error_msg=None) except Exception as x: print("Cache-Tier: Error verifying request: ".format(repr(x))) return flask.json.jsonify( available=False, file=file_name, error=True, error_msg=str(x))