forked from platformio/platformio-core
Catch UnicodeError when saving content cache
This commit is contained in:
@ -210,10 +210,17 @@ class ContentCache(object):
|
|||||||
|
|
||||||
if not isdir(dirname(cache_path)):
|
if not isdir(dirname(cache_path)):
|
||||||
os.makedirs(dirname(cache_path))
|
os.makedirs(dirname(cache_path))
|
||||||
with codecs.open(cache_path, "wb") as fp:
|
try:
|
||||||
fp.write(str(data))
|
with codecs.open(cache_path, "wb") as fp:
|
||||||
with codecs.open(self._db_path, "a") as fp:
|
fp.write(data)
|
||||||
fp.write("%s=%s\n" % (str(expire_time), cache_path))
|
with codecs.open(self._db_path, "a") as fp:
|
||||||
|
fp.write("%s=%s\n" % (str(expire_time), cache_path))
|
||||||
|
except UnicodeError:
|
||||||
|
if isfile(cache_path):
|
||||||
|
try:
|
||||||
|
remove(cache_path)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
return self._unlock_dbindex()
|
return self._unlock_dbindex()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user