bootstrap: fix DeprecationWarning

DeprecationWarning: Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata. Use the filter argument to control this behavior.

See:
https://docs.python.org/3.12/library/tarfile.html#tarfile-extraction-filter
This commit is contained in:
Guðni Már Gilbert 2024-07-27 21:37:43 +00:00 committed by gudnimg
parent ff16bfd8fa
commit a926675c35
1 changed files with 6 additions and 1 deletions

View File

@ -19,6 +19,7 @@ import tarfile
import zipfile import zipfile
from argparse import ArgumentParser from argparse import ArgumentParser
from pathlib import Path from pathlib import Path
from tarfile import TarFile
from urllib.request import urlretrieve from urllib.request import urlretrieve
project_root_dir = Path(__file__).resolve().parent.parent project_root_dir = Path(__file__).resolve().parent.parent
@ -92,7 +93,11 @@ def download_and_unzip(url: str, directory: Path):
obj = tarfile.open(f) obj = tarfile.open(f)
else: else:
obj = zipfile.ZipFile(f, 'r') obj = zipfile.ZipFile(f, 'r')
obj.extractall(path=str(extract_dir))
if isinstance(obj, TarFile):
obj.extractall(path=str(extract_dir), filter='data')
else: # Zip file
obj.extractall(path=str(extract_dir))
subdir = find_single_subdir(extract_dir) subdir = find_single_subdir(extract_dir)
shutil.move(str(subdir), str(directory)) shutil.move(str(subdir), str(directory))