From abdcec397549450492171c920c5e0d3bf19b37ba Mon Sep 17 00:00:00 2001 From: Latrolage <67372293+Latrolage@users.noreply.github.com> Date: Fri, 27 May 2022 09:11:11 +0000 Subject: [PATCH] Retry if league lockfile wasn't openable --- leaguefiles.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/leaguefiles.cpp b/leaguefiles.cpp index ab0b713..ce96ee0 100644 --- a/leaguefiles.cpp +++ b/leaguefiles.cpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include struct leagueDBfind { std::string installlocation, XDG_DATA_HOME, databaselocation, lockfile="0"; @@ -53,10 +55,10 @@ std::ifstream getfile() { //Get credentials from lockfile std::ifstream lockfile(database.lockfile); std::cout << "lockfile location: " << database.lockfile << std::endl; #endif - if (!lockfile.is_open()) { // if it didn't get anything, something went wrong - std::cout << "League isn't open yet or something else went wrong" << std::endl; - // MessageBox(NULL,"League isn't open yet?", "Error!", MB_OK); winblows? - exit(1); + while (!lockfile.is_open()) { // if it didn't get anything, something went wrong. Retry until process is killed + std::cout << "League isn't open yet or something else went wrong. Retrying..." << std::endl; + lockfile.open(database.lockfile); + std::this_thread::sleep_for(std::chrono::seconds(2)); } return lockfile; }