From f6fc0fc424a35c67d257012c9574bc60537f63b4 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sun, 18 Aug 2024 12:50:20 +0200 Subject: Spamming entries seem to have broken the exporter, so we're dealing with a lot of corrupt files. Add helpers that fix these entries up --- makecolumns.sh | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'makecolumns.sh') diff --git a/makecolumns.sh b/makecolumns.sh index 1a0e271..cef88e0 100755 --- a/makecolumns.sh +++ b/makecolumns.sh @@ -373,6 +373,18 @@ handle_format_version_3() { rm ??_unknown } +fix_broken_v4_file() { + name=$1 + offset=$2 + nullbytes=$3 + gap=$4 + + head -c $(( offset - 1 )) file_${name} > file_${name}_ + [ "${nullbytes}" -gt 0 ] && printf '\x00' >> file_${name}_ + tail -c +$(( offset + gap )) file_${name} >> file_${name}_ + mv file_${name}_ file_${name} +} + handle_format_version_4() { if [ -f "$1/branchcodes.tl" ]; then is_yp=true @@ -392,12 +404,24 @@ handle_format_version_4() { printf "Extracting phonebook.db ... " extract_version_4 "$1/phonebook.db" - # Fixup broken file in 2023_Q1 - case $1 in *2023_Q1*) - head -c 442 file_17F0A > file_17F0A_ - printf '\0' >> file_17F0A_ - tail -c +536 file_17F0A >> file_17F0A_ - mv file_17F0A_ file_17F0A + case $1 in + *2023_Q1*) + # Fixup broken file in 2023_Q1 + fix_broken_v4_file 17F0A 0x01BB 1 93 + ;; + *2023_Q3*) + # Fixup broken file in 2023_Q3 + fix_broken_v4_file 15DB2 0x3D05 0 373 + fix_broken_v4_file 15DBD 0x8CA8 0 391 + fix_broken_v4_file 15DD3 0x72B7 0 120 + fix_broken_v4_file 15E2B 0x0549 0 2051 + fix_broken_v4_file 15EE6 0x0569 1 144 + fix_broken_v4_file 15F28 0x2EF8 0 103 + fix_broken_v4_file 15F3E 0x3C1C 0 164 + fix_broken_v4_file 16348 0x0942 0 221 + fix_broken_v4_file 16419 0x0CF8 0 140 + fix_broken_v4_file 16471 0x0681 0 106 + ;; esac rows=`find . -name file_\* | wc -l` -- cgit v1.2.3