From 7b2f1494b944b89660122f78bd18a183e2a46094 Mon Sep 17 00:00:00 2001 From: jutty Date: Sun, 1 Sep 2024 22:23:28 -0300 Subject: [PATCH] Refactor directory variable names for uniformity --- src/package/package_conflict_input_parser.sh | 4 ++-- src/package/package_conflict_resolution.sh | 8 ++++---- src/utility.sh | 12 ++++++++---- tori | 7 ++++--- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/package/package_conflict_input_parser.sh b/src/package/package_conflict_input_parser.sh index 6c5d9e7..547db98 100644 --- a/src/package/package_conflict_input_parser.sh +++ b/src/package/package_conflict_input_parser.sh @@ -1,8 +1,8 @@ package_conflict_input_parser() { local packages="$1" local conflict_type="$2" - local input="$TMP_DIR/package_conflict_input" - local input_choices="$TMP_DIR/package_conflict_input_choices" + local input="$TMP_ROOT/package_conflict_input" + local input_choices="$TMP_ROOT/package_conflict_input_choices" local choices= local packages_to_install= local packages_to_uninstall= diff --git a/src/package/package_conflict_resolution.sh b/src/package/package_conflict_resolution.sh index f2ba8dd..e7b4efc 100644 --- a/src/package/package_conflict_resolution.sh +++ b/src/package/package_conflict_resolution.sh @@ -3,18 +3,18 @@ resolve_packages() { local input_packages= # shellcheck disable=SC2154 - ( echo "$system_packages" > "$TMP_DIR/system_packages" - echo "$user_packages" > "$TMP_DIR/user_packages" ) + ( echo "$system_packages" > "$TMP_ROOT/system_packages" + echo "$user_packages" > "$TMP_ROOT/user_packages" ) local packages_not_on_configuration="$(grep -v -x -f \ - "$TMP_DIR/user_packages" "$TMP_DIR/system_packages" | xargs)" + "$TMP_ROOT/user_packages" "$TMP_ROOT/system_packages" | xargs)" if [ -n "$packages_not_on_configuration" ]; then not_on_configuration_dialog "$packages_not_on_configuration" fi local packages_not_installed=$(grep -v -x -f \ - "$TMP_DIR/system_packages" "$TMP_DIR/user_packages" | xargs) + "$TMP_ROOT/system_packages" "$TMP_ROOT/user_packages" | xargs) if [ -n "$packages_not_installed" ]; then not_installed_dialog "$packages_not_installed" diff --git a/src/utility.sh b/src/utility.sh index b342897..82a8e91 100644 --- a/src/utility.sh +++ b/src/utility.sh @@ -124,12 +124,16 @@ set_opts() { } prepare_directories() { - if ! [ -d "$TMP_DIR" ]; then - mkdir "$TMP_DIR" + if ! [ -d "$TMP_ROOT" ]; then + mkdir "$TMP_ROOT" fi - if ! [ -d "$CACHE_DIR" ]; then - mkdir -p "$CACHE_DIR" + if ! [ -d "$CACHE_ROOT" ]; then + mkdir -p "$CACHE_ROOT" + fi + + if ! [ -d "$BACKUP_ROOT" ]; then + mkdir -p "$BACKUP_ROOT" fi if ! [ -d "$CONFIG_ROOT" ]; then diff --git a/tori b/tori index 6009659..e2e92e7 100755 --- a/tori +++ b/tori @@ -5,8 +5,9 @@ main() { VERSION="0.5.0 2024-07-18" TORI_ROOT="$HOME/.local/share/tori" CONFIG_ROOT="$HOME/.config/tori" - TMP_DIR="/tmp/tori" - CACHE_DIR="$HOME/.cache/tori" + BACKUP_ROOT="$HOME/.local/state/tori/backup" + TMP_ROOT="/tmp/tori" + CACHE_ROOT="$HOME/.cache/tori" # os-independent state @@ -25,7 +26,7 @@ main() { ## os-dependent state OS="$(get_operating_system)" - PACKAGE_CACHE="$CACHE_DIR/${OS}_packages.cache" + PACKAGE_CACHE="$CACHE_ROOT/${OS}_packages.cache" base_files= bkp_files=