From 1b56d6f15a1f82097568d6218650dea6318414cf Mon Sep 17 00:00:00 2001 From: flb Date: Mon, 21 Sep 2020 08:53:59 +0200 Subject: [PATCH] Fixed stuck extracting progress bar --- Makefile | 2 +- include/constants.hpp | 1 + source/extract.cpp | 5 +++-- source/utils.cpp | 26 +++++++++++++++++++++++++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index bd6e7f5..a1f1a38 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ DATA := data INCLUDES := include lib/minizip/include APP_TITLE := AIO Switch Updater APP_AUTHOR := HamletDuFromage -APP_VERSION := 1.0.1 +APP_VERSION := 1.0.3 #ROMFS := $(BUILD)/romfs BOREALIS_PATH := lib/borealis diff --git a/include/constants.hpp b/include/constants.hpp index e92d337..e620eaa 100644 --- a/include/constants.hpp +++ b/include/constants.hpp @@ -10,6 +10,7 @@ #define SIGPATCHES_URL "https://hamletdufromage.github.io/sigpatches-updater/sigpatches.html" #define SIGPATCHES_FILENAME "/config/aio-switch-updater/sigpatches.zip" +#define HEKATE_IPL_PATH "/bootloader/hekate_ipl.ini" #define FIRMWARE_URL "https://hamletdufromage.github.io/switch-fw/firmwares.html" #define FIRMWARE_FILENAME "/config/aio-switch-updater/firmware.zip" diff --git a/source/extract.cpp b/source/extract.cpp index 1964416..40fbc20 100644 --- a/source/extract.cpp +++ b/source/extract.cpp @@ -2,10 +2,11 @@ void extract(const char * filename, const char* workingPath, int overwriteInis){ ProgressEvent::instance().reset(); + ProgressEvent::instance().setStep(1); chdir(workingPath); zipper::Unzipper unzipper(filename); std::vector entries = unzipper.entries(); - ProgressEvent::instance().setTotalSteps(entries.size()); + ProgressEvent::instance().setTotalSteps(entries.size() + 1); for (int i = 0; i < (int) entries.size(); i++){ if(overwriteInis == 0){ if(entries[i].name.substr(entries[i].name.length() - 4) != ".ini") @@ -17,7 +18,7 @@ void extract(const char * filename, const char* workingPath, int overwriteInis){ ProgressEvent::instance().setStep(i); } unzipper.close(); - ProgressEvent::instance().setStep(entries.size()); + ProgressEvent::instance().setStep(ProgressEvent::instance().getMax()); } diff --git a/source/utils.cpp b/source/utils.cpp index 10d8dfb..3bd99ce 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -93,7 +93,31 @@ void extractArchive(archiveType type){ switch(type){ case sigpatches: - if(isArchive(SIGPATCHES_FILENAME)) extract(SIGPATCHES_FILENAME); + if(isArchive(SIGPATCHES_FILENAME)) { + std::string backup(HEKATE_IPL_PATH); + backup += ".old"; + if(std::filesystem::exists(HEKATE_IPL_PATH)){ + dialog->open(); + while(overwriteInis == -1){ + usleep(1); + overwriteInis = dialogResult; + } + dialogResult = -1; + if(overwriteInis == 0){ + std::filesystem::remove(backup); + std::filesystem::rename(HEKATE_IPL_PATH, backup); + extract(SIGPATCHES_FILENAME); + std::filesystem::remove(HEKATE_IPL_PATH); + std::filesystem::rename(backup, HEKATE_IPL_PATH); + } + else{ + extract(SIGPATCHES_FILENAME); + } + } + else{ + extract(SIGPATCHES_FILENAME); + } + } break; case cheats: titles = getInstalledTitlesNs();