diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2024-08-18 12:50:20 +0200 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2024-08-18 12:50:20 +0200 |
| commit | f6fc0fc424a35c67d257012c9574bc60537f63b4 (patch) | |
| tree | cbdc55e7ad7e6b1fe9c75896367349f278538247 | |
| parent | 3a185f73812192059ed28ae4a58d3db7800d072e (diff) | |
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
| -rwxr-xr-x | makecolumns.sh | 36 |
1 files changed, 30 insertions, 6 deletions
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() { | |||
| 373 | rm ??_unknown | 373 | rm ??_unknown |
| 374 | } | 374 | } |
| 375 | 375 | ||
| 376 | fix_broken_v4_file() { | ||
| 377 | name=$1 | ||
| 378 | offset=$2 | ||
| 379 | nullbytes=$3 | ||
| 380 | gap=$4 | ||
| 381 | |||
| 382 | head -c $(( offset - 1 )) file_${name} > file_${name}_ | ||
| 383 | [ "${nullbytes}" -gt 0 ] && printf '\x00' >> file_${name}_ | ||
| 384 | tail -c +$(( offset + gap )) file_${name} >> file_${name}_ | ||
| 385 | mv file_${name}_ file_${name} | ||
| 386 | } | ||
| 387 | |||
| 376 | handle_format_version_4() { | 388 | handle_format_version_4() { |
| 377 | if [ -f "$1/branchcodes.tl" ]; then | 389 | if [ -f "$1/branchcodes.tl" ]; then |
| 378 | is_yp=true | 390 | is_yp=true |
| @@ -392,12 +404,24 @@ handle_format_version_4() { | |||
| 392 | printf "Extracting phonebook.db ... " | 404 | printf "Extracting phonebook.db ... " |
| 393 | extract_version_4 "$1/phonebook.db" | 405 | extract_version_4 "$1/phonebook.db" |
| 394 | 406 | ||
| 395 | # Fixup broken file in 2023_Q1 | 407 | case $1 in |
| 396 | case $1 in *2023_Q1*) | 408 | *2023_Q1*) |
| 397 | head -c 442 file_17F0A > file_17F0A_ | 409 | # Fixup broken file in 2023_Q1 |
| 398 | printf '\0' >> file_17F0A_ | 410 | fix_broken_v4_file 17F0A 0x01BB 1 93 |
| 399 | tail -c +536 file_17F0A >> file_17F0A_ | 411 | ;; |
| 400 | mv file_17F0A_ file_17F0A | 412 | *2023_Q3*) |
| 413 | # Fixup broken file in 2023_Q3 | ||
| 414 | fix_broken_v4_file 15DB2 0x3D05 0 373 | ||
| 415 | fix_broken_v4_file 15DBD 0x8CA8 0 391 | ||
| 416 | fix_broken_v4_file 15DD3 0x72B7 0 120 | ||
| 417 | fix_broken_v4_file 15E2B 0x0549 0 2051 | ||
| 418 | fix_broken_v4_file 15EE6 0x0569 1 144 | ||
| 419 | fix_broken_v4_file 15F28 0x2EF8 0 103 | ||
| 420 | fix_broken_v4_file 15F3E 0x3C1C 0 164 | ||
| 421 | fix_broken_v4_file 16348 0x0942 0 221 | ||
| 422 | fix_broken_v4_file 16419 0x0CF8 0 140 | ||
| 423 | fix_broken_v4_file 16471 0x0681 0 106 | ||
| 424 | ;; | ||
| 401 | esac | 425 | esac |
| 402 | 426 | ||
| 403 | rows=`find . -name file_\* | wc -l` | 427 | rows=`find . -name file_\* | wc -l` |
