base-files: minimize critical time in sysupgrade
authorRodrigo Balerdi <lanchon@gmail.com>
Fri, 15 Apr 2022 10:20:28 +0000 (07:20 -0300)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 19 Apr 2022 15:28:25 +0000 (16:28 +0100)
Attempt to minimize the time during which an interrupted nand sysupgrade
can lead to a non-functional device by flushing caches before starting
the upgrade procedure.

Signed-off-by: Rodrigo Balerdi <lanchon@gmail.com>
package/base-files/files/lib/upgrade/nand.sh

index 371bdf7d77ec71561eb5b52a10dfcae68efd4b6b..5ecdb0ff23636b6a95edf8edf7b33c4f78703700 100644 (file)
@@ -335,15 +335,16 @@ nand_upgrade_tar() {
 
 # Recognize type of passed file and start the upgrade process
 nand_do_upgrade() {
-       local file_type=$(identify $1)
+       local file_type=$(identify "$1")
 
        [ ! "$(find_mtd_index "$CI_UBIPART")" ] && CI_UBIPART=rootfs
 
+       sync
        case "$file_type" in
-               "fit")          nand_upgrade_fit $1;;
-               "ubi")          nand_upgrade_ubinized $1;;
-               "ubifs")        nand_upgrade_ubifs $1;;
-               *)              nand_upgrade_tar $1;;
+               "fit")          nand_upgrade_fit "$1";;
+               "ubi")          nand_upgrade_ubinized "$1";;
+               "ubifs")        nand_upgrade_ubifs "$1";;
+               *)              nand_upgrade_tar "$1";;
        esac
 }