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
if [ ! -d "$folder_path" ]; then local num_files=$(runFileOp find "$folder_path" -maxdepth 1 -type f | wc -l)
isNotice "Folder $folder_name no longer exists — removing it from the database."
runInstallOp sqlite3 "$docker_dir/$db_file" "DELETE FROM apps WHERE name = '$folder_name';" # Check if the folder is empty, contains only a config file, has only a migrate.txt file, or contains both
checkSuccess "Removing $folder_name from the apps database." if [ "$num_files" -eq 0 ]; then
((updated_count++)) isNotice "Uninstalling $folder_name because it is empty."
continue if [[ "$CFG_REQUIREMENT_AUTO_CLEAN_FOLDERS" != "true" ]]; then
fi while true; do
echo ""
local num_files=$(runFileOp find "$folder_path" -maxdepth 1 -type f | wc -l) isQuestion "Would you like to remove $folder_name? *THIS WILL WIPE ALL DATA* (y/n): "
local has_config=false has_migrate=false read -p "" found_empty_remove_choice
[ -f "$folder_path/$folder_name.config" ] && has_config=true if [[ -n "$found_empty_remove_choice" ]]; then
[ -f "$folder_path/migrate.txt" ] && has_migrate=true break
fi
# Describe why the folder counts as a no-data leftover (empty string = isNotice "Please provide a valid input."
# it has real content, so leave it alone). done
local reason="" if [[ "$found_empty_remove_choice" == [yY] ]]; then
if [ "$num_files" -eq 0 ]; then dockerUninstallApp "$folder_name";
reason="empty" fi
elif [ "$num_files" -eq 1 ] && $has_config; then else
reason="only a config file" dockerUninstallApp "$folder_name";
elif [ "$num_files" -eq 1 ] && $has_migrate; then fi
reason="only a migrate.txt marker" elif [ "$num_files" -eq 1 ] && [ -f "$folder_path/$folder_name.config" ]; then
elif [ "$num_files" -eq 2 ] && $has_config && $has_migrate; then isNotice "Uninstalling $folder_name because it contains only a config file."
reason="only a config file and a migrate.txt marker" if [[ "$CFG_REQUIREMENT_AUTO_CLEAN_FOLDERS" != "true" ]]; then
fi while true; do
echo ""
if [[ -n "$reason" ]]; then isQuestion "Would you like to remove $folder_name? *THIS WILL WIPE ALL DATA* (y/n): "
isNotice "Cleaning up $folder_name ($reason — no data to lose)." read -p "" found_empty_remove_choice
dockerUninstallApp "$folder_name" 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 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
} }