A bit more work on the file organization.
This commit is contained in:
@@ -95,33 +95,32 @@ setup_game_zip() {
|
|||||||
rm -rf "$game_dir"
|
rm -rf "$game_dir"
|
||||||
mkdir -p "$game_dir"
|
mkdir -p "$game_dir"
|
||||||
|
|
||||||
# Check if zip has a single top-level directory
|
# Extract to temp location first to handle any ZIP structure
|
||||||
mapfile -t topDirs < <(unzip -l "$zipfile" 2>> "$LOG_FILE" | awk 'NR>3 {print $4}' | grep '/$' | cut -d/ -f1 | sort -u | grep -v '^$')
|
local temp_extract="/tmp/stormux_install_$$"
|
||||||
|
mkdir -p "$temp_extract"
|
||||||
|
|
||||||
if [[ ${#topDirs[@]} -eq 1 ]]; then
|
if ! unzip -q "$zipfile" -d "$temp_extract" 2>> "$LOG_FILE"; then
|
||||||
# Zip has a single top-level dir - extract to temp location, then move
|
echo "Extraction failed" >> "$LOG_FILE"
|
||||||
echo "Single top-level directory detected: ${topDirs[0]}" >> "$LOG_FILE"
|
|
||||||
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
|
|
||||||
|
|
||||||
# Move the extracted directory to final location
|
|
||||||
mv "$temp_extract/${topDirs[0]}" "$game_dir" 2>> "$LOG_FILE"
|
|
||||||
rm -rf "$temp_extract"
|
rm -rf "$temp_extract"
|
||||||
else
|
return 2
|
||||||
# Multiple top-level entries - extract directly to game_dir
|
|
||||||
echo "Multiple top-level entries detected" >> "$LOG_FILE"
|
|
||||||
if ! unzip -q "$zipfile" -d "$game_dir" 2>> "$LOG_FILE"; then
|
|
||||||
echo "Extraction failed" >> "$LOG_FILE"
|
|
||||||
return 2
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check if everything extracted into a single subdirectory
|
||||||
|
local extracted_items
|
||||||
|
extracted_items=("$temp_extract"/*)
|
||||||
|
|
||||||
|
if [[ ${#extracted_items[@]} -eq 1 ]] && [[ -d "${extracted_items[0]}" ]]; then
|
||||||
|
# Single directory - move its contents to game_dir
|
||||||
|
echo "Single directory extracted, moving contents" >> "$LOG_FILE"
|
||||||
|
mv "${extracted_items[0]}"/* "$game_dir/" 2>> "$LOG_FILE"
|
||||||
|
else
|
||||||
|
# Multiple items or single file - move everything
|
||||||
|
echo "Multiple items extracted, moving all" >> "$LOG_FILE"
|
||||||
|
mv "$temp_extract"/* "$game_dir/" 2>> "$LOG_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf "$temp_extract"
|
||||||
|
|
||||||
# Replace NVDA DLLs
|
# Replace NVDA DLLs
|
||||||
replace_nvda_dlls "$game_dir"
|
replace_nvda_dlls "$game_dir"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user