зеркало из https://github.com/mozilla/sccache.git
Bug 1016473 - Gracefully handle bad zip data gotten from storage. r=mshal
This commit is contained in:
Родитель
705e916928
Коммит
9cf47c5849
7
cache.py
7
cache.py
|
@ -4,7 +4,7 @@
|
|||
|
||||
import shutil
|
||||
from cStringIO import StringIO
|
||||
from zipfile import ZipFile, ZIP_DEFLATED
|
||||
from zipfile import ZipFile, ZIP_DEFLATED, BadZipfile
|
||||
|
||||
|
||||
class CacheData(object):
|
||||
|
@ -22,7 +22,10 @@ class CacheData(object):
|
|||
def __init__(self, data=None):
|
||||
self._data = StringIO(data) if data else StringIO()
|
||||
self._obj = {}
|
||||
self._zip = ZipFile(self._data, 'r' if data else 'w', ZIP_DEFLATED)
|
||||
try:
|
||||
self._zip = ZipFile(self._data, 'r' if data else 'w', ZIP_DEFLATED)
|
||||
except BadZipfile:
|
||||
self._zip = ZipFile(self._data, 'w', ZIP_DEFLATED)
|
||||
|
||||
def __getitem__(self, key):
|
||||
if key not in self._obj:
|
||||
|
|
Загрузка…
Ссылка в новой задаче