Skip to content

Commit b28fc12

Browse files
committed
Apply caching only for remote repos (URL/ssh)
Repo inherit cache value based from Program and Global
1 parent 83a1fe0 commit b28fc12

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

mbed/mbed.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,8 @@ def fromurl(cls, url, path=None):
781781
repo.rev = m_repo_url.group(3)
782782
else:
783783
error('Invalid repository (%s)' % url.strip(), -1)
784-
repo.cache = Global().get_cfg('CACHE')
784+
785+
repo.cache = Program(repo.path).get_cfg('CACHE')
785786

786787
return repo
787788

@@ -1016,12 +1017,12 @@ def rm_untracked(self):
10161017

10171018
def get_cache(self, url):
10181019
up = urlparse(formaturl(url, 'https'))
1019-
if self.cache and up and os.path.isdir(os.path.join(self.cache, up.netloc, re.sub(r'^/', '', up.path))):
1020+
if self.cache and up and up.netloc and os.path.isdir(os.path.join(self.cache, up.netloc, re.sub(r'^/', '', up.path))):
10201021
return os.path.join(self.cache, up.netloc, re.sub(r'^/', '', up.path))
10211022

10221023
def set_cache(self, url):
10231024
up = urlparse(formaturl(url, 'https'))
1024-
if self.cache and up and os.path.isdir(self.path):
1025+
if self.cache and up and up.netloc and os.path.isdir(self.path):
10251026
cpath = os.path.join(self.cache, up.netloc, re.sub(r'^/', '', up.path))
10261027
if not os.path.isdir(cpath):
10271028
os.makedirs(cpath)

0 commit comments

Comments
 (0)