summaryrefslogtreecommitdiff
path: root/src/core/hle
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/service/bcat/backend/boxcat.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/core/hle/service/bcat/backend/boxcat.cpp b/src/core/hle/service/bcat/backend/boxcat.cpp
index f37f92bf4..31d2e045c 100644
--- a/src/core/hle/service/bcat/backend/boxcat.cpp
+++ b/src/core/hle/service/bcat/backend/boxcat.cpp
@@ -111,18 +111,16 @@ public:
111 111
112 DownloadResult DownloadDataZip() { 112 DownloadResult DownloadDataZip() {
113 return DownloadInternal(fmt::format(BOXCAT_PATHNAME_DATA, title_id), TIMEOUT_SECONDS, 113 return DownloadInternal(fmt::format(BOXCAT_PATHNAME_DATA, title_id), TIMEOUT_SECONDS,
114 "Boxcat-Data-Digest", "application/zip"); 114 "application/zip");
115 } 115 }
116 116
117 DownloadResult DownloadLaunchParam() { 117 DownloadResult DownloadLaunchParam() {
118 return DownloadInternal(fmt::format(BOXCAT_PATHNAME_LAUNCHPARAM, title_id), 118 return DownloadInternal(fmt::format(BOXCAT_PATHNAME_LAUNCHPARAM, title_id),
119 TIMEOUT_SECONDS / 3, "Boxcat-LaunchParam-Digest", 119 TIMEOUT_SECONDS / 3, "application/octet-stream");
120 "application/octet-stream");
121 } 120 }
122 121
123private: 122private:
124 DownloadResult DownloadInternal(const std::string& resolved_path, u32 timeout_seconds, 123 DownloadResult DownloadInternal(const std::string& resolved_path, u32 timeout_seconds,
125 const std::string& digest_header_name,
126 const std::string& content_type_name) { 124 const std::string& content_type_name) {
127 if (client == nullptr) { 125 if (client == nullptr) {
128 client = std::make_unique<httplib::SSLClient>(BOXCAT_HOSTNAME, PORT, timeout_seconds); 126 client = std::make_unique<httplib::SSLClient>(BOXCAT_HOSTNAME, PORT, timeout_seconds);
@@ -136,10 +134,13 @@ private:
136 134
137 if (FileUtil::Exists(path)) { 135 if (FileUtil::Exists(path)) {
138 FileUtil::IOFile file{path, "rb"}; 136 FileUtil::IOFile file{path, "rb"};
139 std::vector<u8> bytes(file.GetSize()); 137 if (file.IsOpen()) {
140 file.ReadBytes(bytes.data(), bytes.size()); 138 std::vector<u8> bytes(file.GetSize());
141 const auto digest = DigestFile(bytes); 139 file.ReadBytes(bytes.data(), bytes.size());
142 headers.insert({digest_header_name, Common::HexArrayToString(digest, false)}); 140 const auto digest = DigestFile(bytes);
141 headers.insert(
142 {std::string("If-None-Match"), Common::HexArrayToString(digest, false)});
143 }
143 } 144 }
144 145
145 const auto response = client->Get(resolved_path.c_str(), headers); 146 const auto response = client->Get(resolved_path.c_str(), headers);
@@ -227,7 +228,7 @@ void SynchronizeInternal(DirectoryGetter dir_getter, TitleIDVersion title,
227 FileUtil::IOFile zip{zip_path, "rb"}; 228 FileUtil::IOFile zip{zip_path, "rb"};
228 const auto size = zip.GetSize(); 229 const auto size = zip.GetSize();
229 std::vector<u8> bytes(size); 230 std::vector<u8> bytes(size);
230 if (size == 0 || zip.ReadBytes(bytes.data(), bytes.size()) != bytes.size()) { 231 if (!zip.IsOpen() || size == 0 || zip.ReadBytes(bytes.data(), bytes.size()) != bytes.size()) {
231 LOG_ERROR(Service_BCAT, "Boxcat failed to read ZIP file at path '{}'!", zip_path); 232 LOG_ERROR(Service_BCAT, "Boxcat failed to read ZIP file at path '{}'!", zip_path);
232 failure(); 233 failure();
233 return; 234 return;
@@ -335,7 +336,7 @@ std::optional<std::vector<u8>> Boxcat::GetLaunchParameter(TitleIDVersion title)
335 FileUtil::IOFile bin{path, "rb"}; 336 FileUtil::IOFile bin{path, "rb"};
336 const auto size = bin.GetSize(); 337 const auto size = bin.GetSize();
337 std::vector<u8> bytes(size); 338 std::vector<u8> bytes(size);
338 if (size == 0 || bin.ReadBytes(bytes.data(), bytes.size()) != bytes.size()) { 339 if (!bin.IsOpen() || size == 0 || bin.ReadBytes(bytes.data(), bytes.size()) != bytes.size()) {
339 LOG_ERROR(Service_BCAT, "Boxcat failed to read launch parameter binary at path '{}'!", 340 LOG_ERROR(Service_BCAT, "Boxcat failed to read launch parameter binary at path '{}'!",
340 path); 341 path);
341 return std::nullopt; 342 return std::nullopt;