浏览代码

Restore apps in a loop

Bob Mottram 8 年前
父节点
当前提交
91dfd1df51
共有 1 个文件被更改,包括 72 次插入67 次删除
  1. 72
    67
      src/freedombone-controlpanel

+ 72
- 67
src/freedombone-controlpanel 查看文件

@@ -906,96 +906,101 @@ function restore_data_from_storage {
906 906
 
907 907
     detect_apps
908 908
 
909
-    app_list=()
910
-    AllStr=$"all"
911
-    n=1
912
-    applist="$n $AllStr off"
913
-    n=$[n+1]
914
-
915
-    util_index=0
916
-    for a in "${utils_installed[@]}"
909
+    while true
917 910
     do
918
-        applist="$applist $n $a off"
919
-        app_name=${utils_installed[util_index]}
911
+
912
+        app_list=()
913
+        AllStr=$"all"
914
+        n=1
915
+        applist="$n $AllStr off"
920 916
         n=$[n+1]
921
-        util_index=$[util_index+1]
922
-        app_list+=("$app_name")
923
-    done
924 917
 
925
-    app_index=0
926
-    for a in "${APPS_INSTALLED_NAMES[@]}"
927
-    do
928
-        applist="$applist $n $a off"
918
+        util_index=0
919
+        for a in "${utils_installed[@]}"
920
+        do
921
+            applist="$applist $n $a off"
922
+            app_name=${utils_installed[util_index]}
923
+            n=$[n+1]
924
+            util_index=$[util_index+1]
925
+            app_list+=("$app_name")
926
+        done
927
+
928
+        app_index=0
929
+        for a in "${APPS_INSTALLED_NAMES[@]}"
930
+        do
931
+            applist="$applist $n $a off"
932
+            n=$[n+1]
933
+            app_name=${APPS_INSTALLED_NAMES[app_index]}
934
+            app_index=$[app_index+1]
935
+            app_list+=("$app_name")
936
+        done
937
+        ExitStr=$"Exit"
938
+        applist="$applist $n $ExitStr on"
929 939
         n=$[n+1]
930
-        app_name=${APPS_INSTALLED_NAMES[app_index]}
931
-        app_index=$[app_index+1]
932
-        app_list+=("$app_name")
933
-    done
934
-    ExitStr=$"Exit"
935
-    applist="$applist $n $ExitStr on"
936
-    n=$[n+1]
937 940
 
938
-    choices=$(dialog --stdout --backtitle $"Freedombone" \
939
-                     --title $"Restore apps" \
940
-                     --radiolist $'Choose:' \
941
-                     30 40 20 $applist)
941
+        choices=$(dialog --stdout --backtitle $"Freedombone" \
942
+                         --title $"Restore apps" \
943
+                         --radiolist $'Choose:' \
944
+                         30 40 20 $applist)
942 945
 
943
-    sel=$?
944
-    case $sel in
945
-        1) return;;
946
-        255) return;;
947
-    esac
948
-    app_name=$(cat $data)
946
+        sel=$?
947
+        case $sel in
948
+            1) return;;
949
+            255) return;;
950
+        esac
951
+        app_name=$(cat $data)
949 952
 
950
-    # exit
951
-    if [[ $app_name == "$ExitStr" ]]; then
952
-        return
953
-    fi
953
+        # exit
954
+        if [[ $app_name == "$ExitStr" ]]; then
955
+            break
956
+        fi
954 957
 
955
-    clear
958
+        clear
959
+
960
+        # Restore all
961
+        if [[ $app_name == "$AllStr" ]]; then
962
+            $restore_command
963
+            retcode="$?"
964
+            if [[ "$retcode" != "0" ]]; then
965
+                if [[ "$1" == "local" ]]; then
966
+                    dialog --title $"Restore all apps from USB" \
967
+                           --msgbox $"Restore failed with code $retcode" 6 60
968
+                else
969
+                    dialog --title $"Restore all apps from $1" \
970
+                           --msgbox $"Restore failed with code $retcode" 6 60
971
+                fi
972
+                break
973
+            fi
956 974
 
957
-    # Restore all
958
-    if [[ $app_name == "$AllStr" ]]; then
959
-        $restore_command
960
-        retcode="$?"
961
-        if [[ "$retcode" != "0" ]]; then
962 975
             if [[ "$1" == "local" ]]; then
963 976
                 dialog --title $"Restore all apps from USB" \
964
-                       --msgbox $"Restore failed with code $retcode" 6 60
977
+                       --msgbox $"Restore complete" 6 40
965 978
             else
966 979
                 dialog --title $"Restore all apps from $1" \
967
-                       --msgbox $"Restore failed with code $retcode" 6 60
980
+                       --msgbox $"Restore complete" 6 40
968 981
             fi
982
+            break
983
+        fi
984
+
985
+        # Restore an app
986
+        $restore_command "${app_name}"
987
+        retcode="$?"
988
+        if [[ "$retcode" != "0" ]]; then
989
+            dialog --title $"Restore apps from USB" \
990
+                   --msgbox $"Restore of ${app_name} failed with code $retcode" 6 60
969 991
             return
970 992
         fi
971 993
 
994
+        # finished
972 995
         if [[ "$1" == "local" ]]; then
973
-            dialog --title $"Restore all apps from USB" \
996
+            dialog --title $"Restore apps from USB" \
974 997
                    --msgbox $"Restore complete" 6 40
975 998
         else
976
-            dialog --title $"Restore all apps from $1" \
999
+            dialog --title $"Restore apps from $1" \
977 1000
                    --msgbox $"Restore complete" 6 40
978 1001
         fi
979
-        return
980
-    fi
981
-
982
-    # Restore an app
983
-    $restore_command "${app_name}"
984
-    retcode="$?"
985
-    if [[ "$retcode" != "0" ]]; then
986
-        dialog --title $"Restore apps from USB" \
987
-               --msgbox $"Restore of ${app_name} failed with code $retcode" 6 60
988
-        return
989
-    fi
990 1002
 
991
-    # finished
992
-    if [[ "$1" == "local" ]]; then
993
-        dialog --title $"Restore apps from USB" \
994
-               --msgbox $"Restore complete" 6 40
995
-    else
996
-        dialog --title $"Restore apps from $1" \
997
-               --msgbox $"Restore complete" 6 40
998
-    fi
1003
+    done
999 1004
 }
1000 1005
 
1001 1006
 function restore_data {