Skip to content

Commit 024b3ad

Browse files
committed
Prevent filesystem and OS errors during caching to stop the import/clone process
1 parent d4a7d5c commit 024b3ad

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

mbed/mbed.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,14 +1028,17 @@ def get_cache(self, url):
10281028
def set_cache(self, url):
10291029
up = urlparse(formaturl(url, 'https'))
10301030
if self.cache and up and up.netloc and os.path.isdir(self.path):
1031-
cpath = os.path.join(self.cache, up.netloc, re.sub(r'^/', '', up.path))
1032-
if not os.path.isdir(cpath):
1033-
os.makedirs(cpath)
1034-
1035-
scm_dir = '.'+self.scm.name
1036-
if os.path.isdir(os.path.join(cpath, scm_dir)):
1037-
rmtree_readonly(os.path.join(cpath, scm_dir))
1038-
shutil.copytree(os.path.join(self.path, scm_dir), os.path.join(cpath, scm_dir))
1031+
try:
1032+
cpath = os.path.join(self.cache, up.netloc, re.sub(r'^/', '', up.path))
1033+
if not os.path.isdir(cpath):
1034+
os.makedirs(cpath)
1035+
1036+
scm_dir = '.'+self.scm.name
1037+
if os.path.isdir(os.path.join(cpath, scm_dir)):
1038+
rmtree_readonly(os.path.join(cpath, scm_dir))
1039+
shutil.copytree(os.path.join(self.path, scm_dir), os.path.join(cpath, scm_dir))
1040+
except (IOError, OSError, WindowsError):
1041+
warning("Unable to cache \"%s\" to \"%s\"" % (self.path, cpath))
10391042
return False
10401043

10411044
def can_update(self, clean, force):

0 commit comments

Comments
 (0)