Fix really silly obvious issue with nsz installs

This commit is contained in:
Huntereb 2019-11-05 21:13:41 -05:00
parent 636106a7d4
commit 1c4c7e6694

View file

@ -86,6 +86,8 @@ namespace nspInstStuff {
inst::ui::loadInstallScreen(); inst::ui::loadInstallScreen();
bool nspInstalled = true; bool nspInstalled = true;
FsStorageId m_destStorageId = FsStorageId_SdCard; FsStorageId m_destStorageId = FsStorageId_SdCard;
std::vector<std::string> filesToBeRenamed = {};
std::vector<std::string> oldNamesOfFiles = {};
if (whereToInstall) m_destStorageId = FsStorageId_NandUser; if (whereToInstall) m_destStorageId = FsStorageId_NandUser;
@ -94,12 +96,12 @@ namespace nspInstStuff {
for (unsigned int i = 0; i < ourNspList.size(); i++) { for (unsigned int i = 0; i < ourNspList.size(); i++) {
inst::ui::setTopInstInfoText("Installing " + inst::util::shortenString(ourNspList[i].string().erase(0, 6), 48, true)); inst::ui::setTopInstInfoText("Installing " + inst::util::shortenString(ourNspList[i].string().erase(0, 6), 48, true));
bool isNsz = false;
if (ourNspList[i].extension() == ".nsz") { if (ourNspList[i].extension() == ".nsz") {
std::string newfilename = ourNspList[i].string().substr(0, ourNspList[i].string().find_last_of('.'))+".nsp"; oldNamesOfFiles.push_back(ourNspList[i]);
ourNspList[i] = newfilename; std::string newfilename = ourNspList[i].string().substr(0, ourNspList[i].string().find_last_of('.'))+"_temp.nsp";
rename(ourNspList[i], newfilename); rename(ourNspList[i], newfilename);
isNsz = true; filesToBeRenamed.push_back(newfilename);
ourNspList[i] = newfilename;
} }
std::string path = "@Sdcard://" + ourNspList[i].string().erase(0, 6); std::string path = "@Sdcard://" + ourNspList[i].string().erase(0, 6);
@ -114,12 +116,6 @@ namespace nspInstStuff {
task.Prepare(); task.Prepare();
task.Begin(); task.Begin();
if (isNsz && ourNspList[i].extension() == ".nsp") {
std::string newfilename = ourNspList[i].string().substr(0, ourNspList[i].string().find_last_of('.'))+".nsz";
ourNspList[i] = newfilename;
rename(ourNspList[i], newfilename);
}
} }
} }
catch (std::exception& e) catch (std::exception& e)
@ -133,6 +129,13 @@ namespace nspInstStuff {
nspInstalled = false; nspInstalled = false;
} }
for (unsigned int i = 0; i < filesToBeRenamed.size(); i++) {
if (ourNspList.size() == 1) ourNspList[0] = oldNamesOfFiles[i];
if (std::filesystem::exists(filesToBeRenamed[i])) {
rename(filesToBeRenamed[i].c_str(), oldNamesOfFiles[i].c_str());
}
}
if(nspInstalled) { if(nspInstalled) {
inst::ui::setInstInfoText("Install complete"); inst::ui::setInstInfoText("Install complete");
inst::ui::setInstBarPerc(100); inst::ui::setInstBarPerc(100);