Tell how many nsps installed, and which ones failed to install

This commit is contained in:
Huntereb 2019-11-08 11:02:25 -05:00
parent e3e07541d8
commit 9a59359bd0
2 changed files with 21 additions and 19 deletions

View file

@ -121,14 +121,15 @@ namespace netInstStuff{
FsStorageId m_destStorageId = FsStorageId_SdCard; FsStorageId m_destStorageId = FsStorageId_SdCard;
if (ourStorage) m_destStorageId = FsStorageId_NandUser; if (ourStorage) m_destStorageId = FsStorageId_NandUser;
unsigned int urlItr;
try { try {
for (unsigned int i = 0; i < ourUrlList.size(); i++) { for (urlItr = 0; urlItr < ourUrlList.size(); urlItr++) {
inst::ui::setTopInstInfoText("Installing " + inst::util::shortenString(inst::util::formatUrlString(ourUrlList[i]), 48, true)); inst::ui::setTopInstInfoText("Installing " + inst::util::shortenString(inst::util::formatUrlString(ourUrlList[urlItr]), 48, true));
tin::install::nsp::HTTPNSP httpNSP(ourUrlList[i]); tin::install::nsp::HTTPNSP httpNSP(ourUrlList[urlItr]);
printf("%s %s\n", "Install request from", ourUrlList[i].c_str()); printf("%s %s\n", "Install request from", ourUrlList[urlItr].c_str());
tin::install::nsp::RemoteNSPInstall install(m_destStorageId, inst::config::ignoreReqVers, &httpNSP); tin::install::nsp::RemoteNSPInstall install(m_destStorageId, inst::config::ignoreReqVers, &httpNSP);
printf("%s\n", "Preparing installation"); printf("%s\n", "Preparing installation");
@ -142,9 +143,9 @@ namespace netInstStuff{
printf("Failed to install"); printf("Failed to install");
printf("%s", e.what()); printf("%s", e.what());
fprintf(stdout, "%s", e.what()); fprintf(stdout, "%s", e.what());
inst::ui::setInstInfoText("Failed to install"); inst::ui::setInstInfoText("Failed to install " + inst::util::shortenString(ourUrlList[urlItr].erase(0, 6), 48, true));
inst::ui::setInstBarPerc(0); inst::ui::setInstBarPerc(0);
inst::ui::mainApp->CreateShowDialog("Failed to install!", "Partially installed contents can be removed from the System Settings applet.\n\n" + (std::string)e.what(), {"OK"}, true); inst::ui::mainApp->CreateShowDialog("Failed to install " + inst::util::shortenString(ourUrlList[urlItr].erase(0, 6), 48, true) + "!", "Partially installed contents can be removed from the System Settings applet.\n\n" + (std::string)e.what(), {"OK"}, true);
nspInstalled = false; nspInstalled = false;
} }
@ -156,7 +157,7 @@ namespace netInstStuff{
if(nspInstalled) { if(nspInstalled) {
inst::ui::setInstInfoText("Install complete"); inst::ui::setInstInfoText("Install complete");
inst::ui::setInstBarPerc(100); inst::ui::setInstBarPerc(100);
if (ourUrlList.size() > 1) inst::ui::mainApp->CreateShowDialog("Selected files installed!", nspInstStuff::finishedMessage(), {"OK"}, true); if (ourUrlList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourUrlList.size()) + " files installed successfully!", nspInstStuff::finishedMessage(), {"OK"}, true);
else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(inst::util::formatUrlString(ourUrlList[0]), 48, true) + " installed!", nspInstStuff::finishedMessage(), {"OK"}, true); else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(inst::util::formatUrlString(ourUrlList[0]), 48, true) + " installed!", nspInstStuff::finishedMessage(), {"OK"}, true);
} }

View file

@ -90,21 +90,22 @@ namespace nspInstStuff {
std::vector<std::string> oldNamesOfFiles = {}; std::vector<std::string> oldNamesOfFiles = {};
if (whereToInstall) m_destStorageId = FsStorageId_NandUser; if (whereToInstall) m_destStorageId = FsStorageId_NandUser;
unsigned int nspItr;
try try
{ {
for (unsigned int i = 0; i < ourNspList.size(); i++) { for (nspItr = 0; nspItr < ourNspList.size(); nspItr++) {
inst::ui::setTopInstInfoText("Installing " + inst::util::shortenString(ourNspList[i].string().erase(0, 6), 48, true)); inst::ui::setTopInstInfoText("Installing " + inst::util::shortenString(ourNspList[nspItr].string().erase(0, 6), 48, true));
if (ourNspList[i].extension() == ".nsz") { if (ourNspList[nspItr].extension() == ".nsz") {
oldNamesOfFiles.push_back(ourNspList[i]); oldNamesOfFiles.push_back(ourNspList[nspItr]);
std::string newfilename = ourNspList[i].string().substr(0, ourNspList[i].string().find_last_of('.'))+"_temp.nsp"; std::string newfilename = ourNspList[nspItr].string().substr(0, ourNspList[nspItr].string().find_last_of('.'))+"_temp.nsp";
rename(ourNspList[i], newfilename); rename(ourNspList[nspItr], newfilename);
filesToBeRenamed.push_back(newfilename); filesToBeRenamed.push_back(newfilename);
ourNspList[i] = newfilename; ourNspList[nspItr] = newfilename;
} }
std::string path = "@Sdcard://" + ourNspList[i].string().erase(0, 6); std::string path = "@Sdcard://" + ourNspList[nspItr].string().erase(0, 6);
nx::fs::IFileSystem fileSystem; nx::fs::IFileSystem fileSystem;
fileSystem.OpenFileSystemWithId(path, FsFileSystemType_ApplicationPackage, 0); fileSystem.OpenFileSystemWithId(path, FsFileSystemType_ApplicationPackage, 0);
@ -123,9 +124,9 @@ namespace nspInstStuff {
printf("Failed to install"); printf("Failed to install");
printf("%s", e.what()); printf("%s", e.what());
fprintf(stdout, "%s", e.what()); fprintf(stdout, "%s", e.what());
inst::ui::setInstInfoText("Failed to install"); inst::ui::setInstInfoText("Failed to install " + inst::util::shortenString(ourNspList[nspItr].string().erase(0, 6), 48, true));
inst::ui::setInstBarPerc(0); inst::ui::setInstBarPerc(0);
inst::ui::mainApp->CreateShowDialog("Failed to install!", "Partially installed contents can be removed from the System Settings applet.\n\n" + (std::string)e.what(), {"OK"}, true); inst::ui::mainApp->CreateShowDialog("Failed to install " + inst::util::shortenString(ourNspList[nspItr].string().erase(0, 6), 48, true) + "!", "Partially installed contents can be removed from the System Settings applet.\n\n" + (std::string)e.what(), {"OK"}, true);
nspInstalled = false; nspInstalled = false;
} }
@ -141,12 +142,12 @@ namespace nspInstStuff {
inst::ui::setInstBarPerc(100); inst::ui::setInstBarPerc(100);
if (ourNspList.size() > 1) { if (ourNspList.size() > 1) {
if (inst::config::deletePrompt) { if (inst::config::deletePrompt) {
if(inst::ui::mainApp->CreateShowDialog("Selected files installed! Delete them from the SD card?", "NSP and NSZ files aren't needed anymore after they've been installed", {"No","Yes"}, false) == 1) { if(inst::ui::mainApp->CreateShowDialog(std::to_string(ourNspList.size()) + " files installed successfully! Delete them from the SD card?", "NSP and NSZ files aren't needed anymore after they've been installed", {"No","Yes"}, false) == 1) {
for (long unsigned int i = 0; i < ourNspList.size(); i++) { for (long unsigned int i = 0; i < ourNspList.size(); i++) {
if (std::filesystem::exists(ourNspList[i])) std::filesystem::remove(ourNspList[i]); if (std::filesystem::exists(ourNspList[i])) std::filesystem::remove(ourNspList[i]);
} }
} }
} else inst::ui::mainApp->CreateShowDialog("Selected files installed!", nspInstStuff::finishedMessage(), {"OK"}, true); } else inst::ui::mainApp->CreateShowDialog(std::to_string(ourNspList.size()) + " files installed successfully!", nspInstStuff::finishedMessage(), {"OK"}, true);
} else { } else {
if (inst::config::deletePrompt) { if (inst::config::deletePrompt) {
if(inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourNspList[0].string().erase(0, 6), 48, true) + " installed! Delete it from the SD card?", "NSP and NSZ files aren't needed anymore after they've been installed", {"No","Yes"}, false) == 1) if (std::filesystem::exists(ourNspList[0])) std::filesystem::remove(ourNspList[0]); if(inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourNspList[0].string().erase(0, 6), 48, true) + " installed! Delete it from the SD card?", "NSP and NSZ files aren't needed anymore after they've been installed", {"No","Yes"}, false) == 1) if (std::filesystem::exists(ourNspList[0])) std::filesystem::remove(ourNspList[0]);