Compare commits

..

No commits in common. "116e48699e0617a78f88b5aa73f17d198277be1e" and "9ec3a9e73666214fae5a707d5d701978f30166d5" have entirely different histories.

View File

@ -112,44 +112,94 @@ databaseAppScan()
checkSuccess "All apps are up to date." checkSuccess "All apps are up to date."
fi fi
# Reap leftover app folders that hold no real data: completely empty, or # Check and uninstall apps that contain only a config file, are empty, have only a migrate.txt file, or both
# holding only the regenerable .config and/or the migrate.txt marker. There
# is nothing to lose in any of these cases, so we clean them automatically
# rather than prompting — the old "WIPE ALL DATA" question fired precisely
# when there was no data to wipe.
for folder_name in $folder_names; do for folder_name in $folder_names; do
[[ "$folder_name" == "libreportal" ]] && continue if [[ "$folder_name" != "libreportal" ]]; then
local folder_path="$containers_dir/$folder_name" folder_path="$containers_dir/$folder_name"
if [ -d "$folder_path" ]; then
local num_files=$(runFileOp find "$folder_path" -maxdepth 1 -type f | wc -l)
if [ ! -d "$folder_path" ]; then # Check if the folder is empty, contains only a config file, has only a migrate.txt file, or contains both
isNotice "Folder $folder_name no longer exists — removing it from the database." if [ "$num_files" -eq 0 ]; then
runInstallOp sqlite3 "$docker_dir/$db_file" "DELETE FROM apps WHERE name = '$folder_name';" isNotice "Uninstalling $folder_name because it is empty."
checkSuccess "Removing $folder_name from the apps database." if [[ "$CFG_REQUIREMENT_AUTO_CLEAN_FOLDERS" != "true" ]]; then
((updated_count++)) while true; do
continue echo ""
fi isQuestion "Would you like to remove $folder_name? *THIS WILL WIPE ALL DATA* (y/n): "
read -p "" found_empty_remove_choice
local num_files=$(runFileOp find "$folder_path" -maxdepth 1 -type f | wc -l) if [[ -n "$found_empty_remove_choice" ]]; then
local has_config=false has_migrate=false break
[ -f "$folder_path/$folder_name.config" ] && has_config=true fi
[ -f "$folder_path/migrate.txt" ] && has_migrate=true isNotice "Please provide a valid input."
done
# Describe why the folder counts as a no-data leftover (empty string = if [[ "$found_empty_remove_choice" == [yY] ]]; then
# it has real content, so leave it alone). dockerUninstallApp "$folder_name";
local reason="" fi
if [ "$num_files" -eq 0 ]; then else
reason="empty" dockerUninstallApp "$folder_name";
elif [ "$num_files" -eq 1 ] && $has_config; then fi
reason="only a config file" elif [ "$num_files" -eq 1 ] && [ -f "$folder_path/$folder_name.config" ]; then
elif [ "$num_files" -eq 1 ] && $has_migrate; then isNotice "Uninstalling $folder_name because it contains only a config file."
reason="only a migrate.txt marker" if [[ "$CFG_REQUIREMENT_AUTO_CLEAN_FOLDERS" != "true" ]]; then
elif [ "$num_files" -eq 2 ] && $has_config && $has_migrate; then while true; do
reason="only a config file and a migrate.txt marker" echo ""
fi isQuestion "Would you like to remove $folder_name? *THIS WILL WIPE ALL DATA* (y/n): "
read -p "" found_empty_remove_choice
if [[ -n "$reason" ]]; then if [[ -n "$found_empty_remove_choice" ]]; then
isNotice "Cleaning up $folder_name ($reason — no data to lose)." break
dockerUninstallApp "$folder_name" fi
isNotice "Please provide a valid input."
done
if [[ "$found_empty_remove_choice" == [yY] ]]; then
dockerUninstallApp "$folder_name";
fi
else
dockerUninstallApp "$folder_name";
fi
elif [ "$num_files" -eq 1 ] && [ -f "$folder_path/migrate.txt" ]; then
isNotice "Uninstalling $folder_name because it contains only a migrate.txt file."
if [[ "$CFG_REQUIREMENT_AUTO_CLEAN_FOLDERS" != "true" ]]; then
while true; do
echo ""
isQuestion "Would you like to remove $folder_name? *THIS WILL WIPE ALL DATA* (y/n): "
read -p "" found_empty_remove_choice
if [[ -n "$found_empty_remove_choice" ]]; then
break
fi
isNotice "Please provide a valid input."
done
if [[ "$found_empty_remove_choice" == [yY] ]]; then
dockerUninstallApp "$folder_name";
fi
else
dockerUninstallApp "$folder_name";
fi
elif [ "$num_files" -eq 2 ] && [ -f "$folder_path/$folder_name.config" ] && [ -f "$folder_path/migrate.txt" ]; then
isNotice "Uninstalling $folder_name because it contains both a config file and a migrate.txt file."
if [[ "$CFG_REQUIREMENT_AUTO_CLEAN_FOLDERS" != "true" ]]; then
while true; do
echo ""
isQuestion "Would you like to remove $folder_name? *THIS WILL WIPE ALL DATA* (y/n): "
read -p "" found_empty_remove_choice
if [[ -n "$found_empty_remove_choice" ]]; then
break
fi
isNotice "Please provide a valid input."
done
if [[ "$found_empty_remove_choice" == [yY] ]]; then
dockerUninstallApp "$folder_name";
fi
else
dockerUninstallApp "$folder_name";
fi
fi
else
# If the folder doesn't exist in the directory, uninstall it from the database
isNotice "Folder $folder_name does not exist. Removing from the Database."
local result=$(runInstallOp sqlite3 "$docker_dir/$db_file" "DELETE FROM apps WHERE name = '$folder_name';")
checkSuccess "Removing $folder_name from the apps database."
((updated_count++)) # Increment updated_count
fi
fi fi
done done
} }