summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar liamwhite2023-07-06 18:57:25 -0400
committerGravatar GitHub2023-07-06 18:57:25 -0400
commit45ea712d39ca1ef69ecd7a016c7c07d38050519f (patch)
treeaa12e026be8395575a2f21745866b30fcef5aef2
parentMerge pull request #11022 from ChaseKnowlden/sdl2-next (diff)
parentmain: Use 1_MiB as a constant for copy buffer size (diff)
downloadyuzu-45ea712d39ca1ef69ecd7a016c7c07d38050519f.tar.gz
yuzu-45ea712d39ca1ef69ecd7a016c7c07d38050519f.tar.xz
yuzu-45ea712d39ca1ef69ecd7a016c7c07d38050519f.zip
Merge pull request #10999 from Morph1984/fix-install-progress
main: Fix install progress calculation
-rw-r--r--src/yuzu/main.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 20532416c..6cd557c29 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -178,6 +178,8 @@ constexpr int default_mouse_hide_timeout = 2500;
178constexpr int default_mouse_center_timeout = 10; 178constexpr int default_mouse_center_timeout = 10;
179constexpr int default_input_update_timeout = 1; 179constexpr int default_input_update_timeout = 1;
180 180
181constexpr size_t CopyBufferSize = 1_MiB;
182
181/** 183/**
182 * "Callouts" are one-time instructional messages shown to the user. In the config settings, there 184 * "Callouts" are one-time instructional messages shown to the user. In the config settings, there
183 * is a bitfield "callout_flags" options, used to track if a message has already been shown to the 185 * is a bitfield "callout_flags" options, used to track if a message has already been shown to the
@@ -2929,10 +2931,10 @@ void GMainWindow::OnMenuInstallToNAND() {
2929 2931
2930 int remaining = filenames.size(); 2932 int remaining = filenames.size();
2931 2933
2932 // This would only overflow above 2^43 bytes (8.796 TB) 2934 // This would only overflow above 2^51 bytes (2.252 PB)
2933 int total_size = 0; 2935 int total_size = 0;
2934 for (const QString& file : files) { 2936 for (const QString& file : files) {
2935 total_size += static_cast<int>(QFile(file).size() / 0x1000); 2937 total_size += static_cast<int>(QFile(file).size() / CopyBufferSize);
2936 } 2938 }
2937 if (total_size < 0) { 2939 if (total_size < 0) {
2938 LOG_CRITICAL(Frontend, "Attempting to install too many files, aborting."); 2940 LOG_CRITICAL(Frontend, "Attempting to install too many files, aborting.");
@@ -3032,7 +3034,7 @@ InstallResult GMainWindow::InstallNSPXCI(const QString& filename) {
3032 return false; 3034 return false;
3033 } 3035 }
3034 3036
3035 std::vector<u8> buffer(1_MiB); 3037 std::vector<u8> buffer(CopyBufferSize);
3036 3038
3037 for (std::size_t i = 0; i < src->GetSize(); i += buffer.size()) { 3039 for (std::size_t i = 0; i < src->GetSize(); i += buffer.size()) {
3038 if (install_progress->wasCanceled()) { 3040 if (install_progress->wasCanceled()) {
@@ -3088,7 +3090,7 @@ InstallResult GMainWindow::InstallNCA(const QString& filename) {
3088 return false; 3090 return false;
3089 } 3091 }
3090 3092
3091 std::array<u8, 0x1000> buffer{}; 3093 std::vector<u8> buffer(CopyBufferSize);
3092 3094
3093 for (std::size_t i = 0; i < src->GetSize(); i += buffer.size()) { 3095 for (std::size_t i = 0; i < src->GetSize(); i += buffer.size()) {
3094 if (install_progress->wasCanceled()) { 3096 if (install_progress->wasCanceled()) {