Broke the zip extraction logic. Hopefully fixed again.

This commit is contained in:
Storm Dragon
2025-10-09 23:29:43 -04:00
parent 88120d448e
commit 2e0abcc14b
+11 -7
View File
@@ -14,7 +14,8 @@ NVDA_DLL_SOURCE="$HOME/.local/games/nvda"
# Initialize logging
init_logging() {
mkdir -p "$LOG_DIR"
echo "=== Installation started at $(date) ===" >> "$LOG_FILE"
# Clear previous log and start fresh
echo "=== Installation started at $(date) ===" > "$LOG_FILE"
}
# Speech output
@@ -98,17 +99,20 @@ setup_game_zip() {
mapfile -t topDirs < <(unzip -l "$zipfile" 2>> "$LOG_FILE" | awk 'NR>3 {print $4}' | grep '/$' | cut -d/ -f1 | sort -u | grep -v '^$')
if [[ ${#topDirs[@]} -eq 1 ]]; then
# Zip has a single top-level dir - extract to parent, then rename if needed
# Zip has a single top-level dir - extract to temp location, then move
echo "Single top-level directory detected: ${topDirs[0]}" >> "$LOG_FILE"
if ! unzip -q "$zipfile" -d "$INSTALL_BASE" 2>> "$LOG_FILE"; then
local temp_extract="/tmp/stormux_install_$$"
mkdir -p "$temp_extract"
if ! unzip -q "$zipfile" -d "$temp_extract" 2>> "$LOG_FILE"; then
echo "Extraction failed" >> "$LOG_FILE"
rm -rf "$temp_extract"
return 2
fi
# If the extracted dir name differs from target, rename it
if [[ "${topDirs[0]}" != "$(basename "$game_dir")" ]]; then
mv "$INSTALL_BASE/${topDirs[0]}" "$game_dir" 2>> "$LOG_FILE"
fi
# Move the extracted directory to final location
mv "$temp_extract/${topDirs[0]}" "$game_dir" 2>> "$LOG_FILE"
rm -rf "$temp_extract"
else
# Multiple top-level entries - extract directly to game_dir
echo "Multiple top-level entries detected" >> "$LOG_FILE"