mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2025-04-10 19:15:12 +00:00
Add repair_paths function to fix paths that cannot be found without needing a full reset
This commit is contained in:
parent
67a77e9932
commit
fea3a3e3c2
|
@ -1128,3 +1128,50 @@ add_retrodeck_to_steam(){
|
|||
|
||||
log i "RetroDECK has been added to Steam"
|
||||
}
|
||||
|
||||
repair_paths() {
|
||||
# This function will verify that all folders defined in the [paths] section of retrodeck.cfg exist
|
||||
# If a folder doesn't exist and is defined outside of rdhome, it will check in rdhome first and have the user browse for them manually if it isn't there either
|
||||
# USAGE: repair_paths
|
||||
|
||||
invalid_path_found="false"
|
||||
|
||||
log i "Checking that all RetroDECK paths are valid"
|
||||
while read -r config_line; do
|
||||
local current_setting_name=$(get_setting_name "$config_line" "retrodeck")
|
||||
if [[ ! $current_setting_name =~ (rdhome|sdcard) ]]; then # Ignore these locations
|
||||
local current_setting_value=$(get_setting_value "$rd_conf" "$current_setting_name" "retrodeck" "paths")
|
||||
if [[ ! -d "$current_setting_value" ]]; then # If the folder doesn't exist as defined
|
||||
log i "$current_setting_name does not exist as defined, config is incorrect"
|
||||
if [[ ! -d "$rdhome/${current_setting_value#*retrodeck/}" ]]; then # If the folder doesn't exist within defined rdhome path
|
||||
if [[ ! -d "$sdcard/${current_setting_value#*retrodeck/}" ]]; then # If the folder doesn't exist within defined sdcard path
|
||||
log i "$current_setting_name cannot be found at any expected location, having user locate it manually"
|
||||
configurator_generic_dialog "RetroDECK Path Repair" "The RetroDECK $current_setting_name was not found in the expected location.\nThis may happen when the folder is moved manually.\n\nPlease browse to the current location of the $current_setting_name."
|
||||
new_path=$(directory_browse "RetroDECK $current_setting_name location")
|
||||
set_setting_value "$rd_conf" "$current_setting_name" "$new_path" retrodeck "paths"
|
||||
invalid_path_found="true"
|
||||
else # Folder does exist within defined sdcard path, update accordingly
|
||||
log i "$current_setting_name found in $sdcard/retrodeck, correcting path config"
|
||||
new_path="$sdcard/retrodeck/${current_setting_value#*retrodeck/}"
|
||||
set_setting_value "$rd_conf" "$current_setting_name" "$new_path" retrodeck "paths"
|
||||
invalid_path_found="true"
|
||||
fi
|
||||
else # Folder does exist within defined rdhome path, update accordingly
|
||||
log i "$current_setting_name found in $rdhome, correcting path config"
|
||||
new_path="$rdhome/${current_setting_value#*retrodeck/}"
|
||||
set_setting_value "$rd_conf" "$current_setting_name" "$new_path" retrodeck "paths"
|
||||
invalid_path_found="true"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done < <(grep -v '^\s*$' $rd_conf | awk '/^\[paths\]/{f=1;next} /^\[/{f=0} f')
|
||||
|
||||
if [[ $invalid_path_found == "true" ]]; then
|
||||
log i "One or more invalid paths repaired, fixing internal RetroDECK structures"
|
||||
conf_read
|
||||
dir_prep "$logs_folder" "$rd_logs_folder"
|
||||
prepare_component "postmove" "all"
|
||||
else
|
||||
log i "All folders were found at their expected locations"
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue