Succesful data exploration

This commit is contained in:
2025-11-19 11:57:59 +01:00
parent 3e47dcd52f
commit dfdd200867
18 changed files with 40849 additions and 12 deletions
+13 -10
View File
@@ -122,24 +122,27 @@ async def extract_adsb_data(cmd: List[str]) -> None:
def extract_tar_sync(tar_paths: List[Path], extract_dir: Path) -> Path:
"""Synchronous tar extraction (CPU-bound, run in thread pool)."""
extract_dir.mkdir(parents=True, exist_ok=True)
if len(tar_paths) == 1:
tar_path = tar_paths[0]
else:
# Concatenate multi-part tar files
tar_paths = [p for p in tar_paths if len(p.suffix) == 3]
tar_path = extract_dir / tar_paths[0].stem
logger.info(f"Concatenating {len(tar_paths)} parts → {pretty_path(tar_path)}")
with open(tar_path, 'wb') as outfile:
for part in tar_paths:
with open(part, 'rb') as infile:
# Keep only multipart fragments like .aa, .ab, .ac ...
parts = [p for p in tar_paths if len(p.suffix) == 3]
# Derive correct base archive name: strip only the multipart suffix
base = parts[0].with_suffix("") # "foo.tar.aa" → "foo.tar"
tar_path = extract_dir / base.name
logger.info(f"Concatenating {len(parts)} parts → {pretty_path(tar_path)}")
with open(tar_path, "wb") as outfile:
for part in sorted(parts):
with open(part, "rb") as infile:
shutil.copyfileobj(infile, outfile)
logger.info(f"Extracting {pretty_path(tar_path)}{pretty_path(extract_dir)}")
with tarfile.open(tar_path) as tf:
tf.extractall(path=extract_dir)
return extract_dir