Skip to content

Commit 326cc6f

Browse files
committed
Move local downloads of repentogon assets from the launcher's root to ./launcher-data/ because a couple people have confused launcher.txt with launcher.log; get it outta here
1 parent 9ec7f4d commit 326cc6f

2 files changed

Lines changed: 28 additions & 16 deletions

File tree

include/launcher/repentogon_installer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ namespace Launcher {
7373
RepentogonInstallationPhase phase = REPENTOGON_INSTALLATION_PHASE_CHECK_ASSETS;
7474
bool zipOk = false; /* zip is present in assets. */
7575
bool hashOk = false; /* hash is present in assets. */
76-
bool launcherversionlock = false;
76+
bool launcherversionlock = false; /* (optional) minimum launcher version is present in assets. */
7777
std::string launcherversionreqUrl; /* URL to check launcher version. */
7878
std::string hashUrl; /* URL to download the hash. */
7979
std::string zipUrl; /* URL to download the archive. */
8080
ScopedFile hashFile; /* Pointer to the file in which we write the hash. */
81-
ScopedFile ReqVersionFile; /* Pointer to the file in which we write the hash. */
81+
ScopedFile ReqVersionFile; /* Pointer to the file in which we write the minimum required launcher version. */
8282
ScopedFile zipFile; /* Pointer to the file in which we write the zip. */
8383
std::string hash; /* Expected hash of the zip file. */
8484
std::string zipHash; /* Hash of the zip file. */

src/repentogon_installer.cpp

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ namespace Launcher {
2525
static const char* RepentogonZipName = "REPENTOGON.zip";
2626
static const char* HashName = "hash.txt";
2727
static const char* ReqLauncherVersionName = "launcher.txt";
28+
static const std::string DownloadedFileBasePath = "./launcher-data/";
29+
static const std::string DownloadedRepentogonZipPath = DownloadedFileBasePath + RepentogonZipName;
30+
static const std::string DownloadedHashPath = DownloadedFileBasePath + HashName;
31+
static const std::string DownloadedReqLauncherVersionPath = DownloadedFileBasePath + ReqLauncherVersionName;
2832

2933
RepentogonInstallationState::RepentogonInstallationState() {
3034

@@ -39,6 +43,18 @@ namespace Launcher {
3943
} else {
4044
_zhlVersion = _loaderVersion = _repentogonVersion = "none";
4145
}
46+
47+
// Downloaded assets were moved from the launcher root to the "launcher-data" folder
48+
// because a couple of people confused launcher.txt with launcher.log
49+
try {
50+
if (fs::exists(ReqLauncherVersionName)) {
51+
fs::remove(RepentogonZipName);
52+
fs::remove(HashName);
53+
fs::remove(ReqLauncherVersionName);
54+
}
55+
} catch (fs::filesystem_error& e) {
56+
Logger::Error("RepentogonInstaller: Failed to clean up legacy files: %s\n", e.what());
57+
}
4258
}
4359

4460
bool RepentogonInstaller::InstallRepentogonThread(rapidjson::Document& response) {
@@ -166,8 +182,6 @@ namespace Launcher {
166182
}
167183

168184
PushNotification(false, "Sucessfully installed Repentogon\n");
169-
170-
171185
Logger::Info("RepentogonInstaller::InstallRepentogonThread: successfully installed Repentogon\n");
172186

173187
_installationState.phase = REPENTOGON_INSTALLATION_PHASE_DONE;
@@ -239,7 +253,6 @@ namespace Launcher {
239253
this, std::ref(document), allowPreReleases, force), &_monitor);
240254
}
241255

242-
243256
RepentogonInstaller::CheckRepentogonUpdatesResult
244257
RepentogonInstaller::CheckRepentogonUpdatesThread(rapidjson::Document& document,
245258
bool allowPreReleases, bool force) {
@@ -254,11 +267,10 @@ namespace Launcher {
254267
}
255268
}
256269
//Gitlab Filter END
270+
257271
Github::VersionCheckResult result = CheckRepentogonUpdatesThread_Updater(document,
258272
allowPreReleases);
259273

260-
261-
262274
if (result == Github::VERSION_CHECK_NEW)
263275
return CHECK_REPENTOGON_UPDATES_NEW;
264276

@@ -434,7 +446,7 @@ namespace Launcher {
434446

435447
Logger::Info("RepentogonInstaller::DownloadRepentogon: Downloading hash from `%s`...\n", request.url.c_str());
436448
std::shared_ptr<curl::AsynchronousDownloadFileDescriptor> hashDownloadDescriptor =
437-
curl::AsyncDownloadFile(request, HashName);
449+
curl::AsyncDownloadFile(request, DownloadedHashPath);
438450
std::optional<curl::DownloadFileDescriptor> hashResult = GithubToRepInstall<curl::DownloadFileDescriptor>(
439451
&hashDownloadDescriptor->base.monitor, hashDownloadDescriptor->result);
440452

@@ -457,7 +469,7 @@ namespace Launcher {
457469
}
458470
}
459471
else {
460-
_installationState.hashFile = fopen(HashName, "r");
472+
_installationState.hashFile = fopen(DownloadedHashPath.c_str(), "r");
461473
}
462474

463475
if (!_installationState.hashFile) {
@@ -472,7 +484,7 @@ namespace Launcher {
472484

473485
Logger::Info("RepentogonInstaller::DownloadRepentogon: Downloading required launcher version from `%s`...\n", request.url.c_str());
474486
std::shared_ptr<curl::AsynchronousDownloadFileDescriptor> ReqLauncherverDownloadDescriptor =
475-
curl::AsyncDownloadFile(request, ReqLauncherVersionName);
487+
curl::AsyncDownloadFile(request, DownloadedReqLauncherVersionPath);
476488
std::optional<curl::DownloadFileDescriptor> reqlauncherResult = GithubToRepInstall<curl::DownloadFileDescriptor>(
477489
&ReqLauncherverDownloadDescriptor->base.monitor, ReqLauncherverDownloadDescriptor->result);
478490

@@ -497,7 +509,7 @@ namespace Launcher {
497509
}
498510
}
499511
else {
500-
_installationState.ReqVersionFile = fopen(ReqLauncherVersionName, "r");
512+
_installationState.ReqVersionFile = fopen(DownloadedReqLauncherVersionPath.c_str(), "r");
501513
}
502514

503515
if (!_installationState.ReqVersionFile) {
@@ -509,7 +521,7 @@ namespace Launcher {
509521

510522
Logger::Info("RepentogonInstaller::DownloadRepentogon: Downloading REPENTOGON zip from `%s`...\n", request.url.c_str());
511523
std::shared_ptr<curl::AsynchronousDownloadFileDescriptor> zipDownloadDesc =
512-
curl::AsyncDownloadFile(request, RepentogonZipName);
524+
curl::AsyncDownloadFile(request, DownloadedRepentogonZipPath);
513525
std::optional<curl::DownloadFileDescriptor> zipResult = GithubToRepInstall<curl::DownloadFileDescriptor>(
514526
&zipDownloadDesc->base.monitor, zipDownloadDesc->result);
515527

@@ -525,15 +537,15 @@ namespace Launcher {
525537
Logger::Error("RepentogonUpdater::DownloadRepentogon: error while downloading zip, trying steam\n");
526538
if (SteamWorkshop::SubscribeDownloadAndGetFile(SteamWorkshop::REPENTOGON_WORKSHOP_ID, "REPENTOGON/" + relpath, filePath)) {
527539
_installationState.zipFile = fopen(filePath.c_str(), "r");
528-
fs::copy_file(filePath,fs::current_path() / RepentogonZipName,fs::copy_options::overwrite_existing); //needed for hashing later
540+
fs::copy_file(filePath, DownloadedRepentogonZipPath, fs::copy_options::overwrite_existing); //needed for hashing later
529541
}
530542
else {
531543
Logger::Error("RepentogonUpdater::DownloadRepentogon: error while downloading zip from steam\n");
532544
return false;
533545
}
534546
}
535547
else {
536-
_installationState.zipFile = fopen(RepentogonZipName, "r");
548+
_installationState.zipFile = fopen(DownloadedRepentogonZipPath.c_str(), "r");
537549
}
538550

539551
if (!_installationState.zipFile) {
@@ -579,7 +591,7 @@ namespace Launcher {
579591
}
580592

581593
std::string zipHash;
582-
HashResult hashResult = Sha256::Sha256F(RepentogonZipName, zipHash);
594+
HashResult hashResult = Sha256::Sha256F(DownloadedRepentogonZipPath.c_str(), zipHash);
583595

584596
if (hashResult != HASH_OK) {
585597
Logger::Fatal("RepentogonUpdater::CheckRepentogonIntegrity: unable "
@@ -627,7 +639,7 @@ namespace Launcher {
627639

628640
std::vector<std::tuple<std::string, bool>>& filesState = _installationState.unzipedFiles;
629641
int zipError;
630-
zip_t* zip = zip_open(RepentogonZipName, ZIP_RDONLY | ZIP_CHECKCONS, &zipError);
642+
zip_t* zip = zip_open(DownloadedRepentogonZipPath.c_str(), ZIP_RDONLY | ZIP_CHECKCONS, &zipError);
631643
if (!zip) {
632644
Logger::Error("RepentogonUpdater::ExtractRepentogon: error %d while opening %s\n", zipError, RepentogonZipName);
633645
return false;

0 commit comments

Comments
 (0)