diff --git a/scripts/download-content.sh b/scripts/download-content.sh index 0df02c9..7a9ba52 100755 --- a/scripts/download-content.sh +++ b/scripts/download-content.sh @@ -29,6 +29,8 @@ mountpoint -q /library || echo "Uyarı / warning: /library ayrı bir disk değil echo ">> Kiwix kataloğu alınıyor / fetching Kiwix catalog" if ! curl -fsSL -m 300 "$CATALOG_URL" -o "$CAT"; then echo "!! Katalog alınamadı, klasör listesine düşülüyor / catalog unreachable, falling back to directory listings" + # CAT boşalınca EXIT trap'i dosyayı silemez, önce sil / once CAT is cleared the EXIT trap can't remove the file + rm -f "$CAT" CAT="" fi @@ -52,6 +54,14 @@ while read -r folder prefix _; do if [ -z "$url" ]; then echo "!! $prefix bulunamadı / not found in the Kiwix catalog (ad değişmiş veya kaldırılmış olabilir / name may have changed or been retired)"; failed=1; continue; fi latest=$(basename "$url") + # Eski sürümlerin yarım indirmelerini sil: yeni sürüm çıkınca bunlara devam edilmez, ama yer + # kaplar ve aşağıdaki yer kontrolünde dolu sayılır. + # Remove unfinished downloads of older versions: they are never resumed once a newer version is + # out, but they take up space and count as used in the free-space check below. + for part in "$DEST/${prefix}"_[0-9][0-9][0-9][0-9]-[0-9][0-9]*.zim.part; do + [ "$part" != "$DEST/$latest.part" ] && [ -f "$part" ] && { echo "-- eski yarım indirme siliniyor / removing stale partial download $part"; rm -f "$part"; } + done + if [ -f "$DEST/$latest" ]; then echo "== $latest zaten var / already present"; continue; fi # Yer kontrolü / free-space check: kalan boyut + pay / remaining bytes + headroom