提交 2dd080a1 编写于 作者: C Cleber Rosa

Asset fetcher: cache relative dir should be computed from name

The name the user gives to the asset fetcher should be the primary
controlling aspect of the cache location.  The possible locations
where the asset might be found are just an aiding component to the
asset retrieval.

This is, besides a fix, also an opmization, given that
_get_relative_dir() is now called only once, instead of once for each
possible location.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 2677c555
......@@ -171,6 +171,7 @@ class Asset(object):
for item in self.locations:
urls.append(item)
cache_relative_dir = self._get_relative_dir(parsed_url)
for url in urls:
urlobj = urlparse.urlparse(url)
if urlobj.scheme in ['http', 'https', 'ftp']:
......@@ -180,7 +181,6 @@ class Asset(object):
else:
raise UnsupportedProtocolError("Unsupported protocol"
": %s" % urlobj.scheme)
cache_relative_dir = self._get_relative_dir(urlobj)
asset_file = os.path.join(cache_dir, cache_relative_dir, basename)
dirname = os.path.dirname(asset_file)
if not os.path.isdir(dirname):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册