fixed Use Remote ZIP Resource

fixed typo
This commit is contained in:
chinosk
2025-03-20 01:20:24 +00:00
parent 4a77a4fc06
commit b38fabd65b
5 changed files with 214 additions and 7 deletions

View File

@@ -130,13 +130,16 @@ namespace GkmsResourceUpdate {
return content;
}
bool unzipFileFromURL(std::string downloadUrl, const std::string& unzipPath) {
bool unzipFileFromURL(std::string downloadUrl, const std::string& unzipPath, const std::string& targetDir = "") {
std::string tempZipFile = (gakumasLocalPath / "temp_download.zip").string();
if (std::filesystem::exists(tempZipFile)) {
std::filesystem::remove(tempZipFile);
}
if (!DownloadFile(downloadUrl, tempZipFile)) {
GakumasLocal::Log::Error("Download zip file failed.");
return false;
}
if (!UnzipFile(tempZipFile, unzipPath)) {
if (!UnzipFile(tempZipFile, unzipPath, targetDir)) {
GakumasLocal::Log::Error("Unzip file failed.");
return false;
}
@@ -214,9 +217,9 @@ namespace GkmsResourceUpdate {
}).detach();
}
void checkUpdateFromURL(std::string downloadUrl) {
std::thread([&downloadUrl]() {
if (unzipFileFromURL(downloadUrl, gakumasLocalPath.string())) {
void checkUpdateFromURL(const std::string& downloadUrl) {
std::thread([downloadUrl]() {
if (unzipFileFromURL(downloadUrl, gakumasLocalPath.string(), "local-files")) {
g_reload_all_data();
GakumasLocal::Log::Info("Update completed.");
}