Skip to content

Commit

Permalink
prevent redundant redownloading of archives for non-english target la…
Browse files Browse the repository at this point in the history
…nguages (#19)

* add gulf arabic

* redownload gz only once per target language
  • Loading branch information
StefanVukovic99 authored Apr 8, 2024
1 parent e3e5237 commit b44a39a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions auto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ for target_lang in "${languages[@]}"; do

export target_iso="$target_iso"
export target_language="$target_language_name"
downloaded_target_extract=false

for source_lang in "${languages[@]}"; do
iso=$(echo "${source_lang}" | jq -r '.iso')
Expand Down Expand Up @@ -117,12 +118,13 @@ for target_lang in "${languages[@]}"; do
target_extract="$target_iso-extract.json"
target_extract_path="data/kaikki/$target_extract"

if [ ! -f "$target_extract_path" ] || [ "$redownload" = true ]; then
if [ ! -f "$target_extract_path" ] || [ "$redownload" = true ] && [ "$downloaded_target_extract" = false ]; then
url="https://kaikki.org/dictionary/downloads/$target_iso/$target_extract.gz"
echo "Downloading $target_extract from $url"
wget "$url" -O "$target_extract_path".gz
echo "Extracting $target_extract"
gunzip "$target_extract_path".gz # Use 'gunzip' to extract the compressed file
gunzip -f "$target_extract_path".gz
downloaded_target_extract=true
else
echo "Kaikki dict already exists. Skipping download."
fi
Expand Down

0 comments on commit b44a39a

Please sign in to comment.