Broke the zip extraction logic. Hopefully fixed again.
This commit is contained in:
1 parent
88120d448e
commit
2e0abcc14b
1 file changed
+11
-7
@@ -14,7 +14,8 @@ NVDA_DLL_SOURCE="$HOME/.local/games/nvda"
|
|||||||
# Initialize logging
|
# Initialize logging
|
||||||
init_logging() {
|
init_logging() {
|
||||||
mkdir -p "$LOG_DIR"
|
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
|
# 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 '^$')
|
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
|
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"
|
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"
|
echo "Extraction failed" >> "$LOG_FILE"
|
||||||
|
rm -rf "$temp_extract"
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If the extracted dir name differs from target, rename it
|
# Move the extracted directory to final location
|
||||||
if [[ "${topDirs[0]}" != "$(basename "$game_dir")" ]]; then
|
mv "$temp_extract/${topDirs[0]}" "$game_dir" 2>> "$LOG_FILE"
|
||||||
mv "$INSTALL_BASE/${topDirs[0]}" "$game_dir" 2>> "$LOG_FILE"
|
rm -rf "$temp_extract"
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
# Multiple top-level entries - extract directly to game_dir
|
# Multiple top-level entries - extract directly to game_dir
|
||||||
echo "Multiple top-level entries detected" >> "$LOG_FILE"
|
echo "Multiple top-level entries detected" >> "$LOG_FILE"
|
||||||
|
|||||||
Reference in new issue
Block a user