Bug 1607411 - Automatically remove broken files from cache r=rwood

when a tarball is broken and in the cache, the condprof client will loop on
trying to extract its content and eventually fail. On any tar extraction error,
we delete the file from the cache to get a fresh on

Differential Revision: https://phabricator.services.mozilla.com/D58917

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tarek Ziadé 2020-01-07 17:23:02 +00:00
Родитель f1826cfaf7
Коммит 8ee894efa8
1 изменённых файлов: 4 добавлений и 0 удалений

Просмотреть файл

@ -98,6 +98,10 @@ def get_profile(
tar.extract = functools.partial(_extract, tar)
tar.extractall(target_dir)
except (OSError, tarfile.ReadError) as e:
LOG("Failed to extract the tarball")
if download_cache and os.path.exists(archive):
LOG("Removing cached file to attempt a new download")
os.remove(archive)
raise ProfileNotFoundError(str(e))
finally:
if not download_cache: