Correct patch for headless operation.

This commit is contained in:
grepwood 2020-04-17 19:23:56 +02:00
parent ccf44033f7
commit 6a34b55db0

View File

@ -1,6 +1,14 @@
--- a/src/downloader.cpp 2020-04-17 15:41:32.142346898 +0200 --- lgogdownloader/src/downloader.cpp 2020-04-17 15:41:32.142346898 +0200
+++ b/src/downloader.cpp 2020-04-17 14:54:23.614337011 +0200 +++ lgogdownloader-portage/src/downloader.cpp 2020-04-17 17:04:49.688606206 +0200
@@ -255,21 +255,27 @@ @@ -246,6 +246,7 @@
{
std::string email;
std::string password;
+ bool headless = false;
if (!Globals::globalConfig.sEmail.empty() && !Globals::globalConfig.sPassword.empty())
{
@@ -255,24 +256,32 @@
else else
{ {
if (!isatty(STDIN_FILENO)) { if (!isatty(STDIN_FILENO)) {
@ -10,12 +18,14 @@
- std::cerr << "Email: "; - std::cerr << "Email: ";
- std::getline(std::cin,email); - std::getline(std::cin,email);
+ /* Attempt to read this stuff from elsewhere */ + /* Attempt to read this stuff from elsewhere */
+ bool cookie_gone = boost::filesystem::exists(Globals::globalConfig.curlConf.sCookiePath); + bool cookie_gone = !(boost::filesystem::exists(Globals::globalConfig.curlConf.sCookiePath));
+ bool tokens_gone = boost::filesystem::exists(Globals::globalConfig.sConfigDirectory + "/galaxy_tokens.json"); + bool tokens_gone = !(boost::filesystem::exists(Globals::globalConfig.sConfigDirectory + "/galaxy_tokens.json"));
+ std::cout << Globals::globalConfig.curlConf.sCookiePath << std::endl;
+ std::cout << (Globals::globalConfig.sConfigDirectory + "/galaxy_tokens.json") << std::endl;
+ if(cookie_gone || tokens_gone) { + if(cookie_gone || tokens_gone) {
+ std::cerr << "Unable to read email and password" << std::endl; + std::cerr << "Unable to read email and password" << std::endl;
+ return 0; + return 0;
+ } + } else headless = true;
+ } else { + } else {
+ std::cerr << "Email: "; + std::cerr << "Email: ";
+ std::getline(std::cin,email); + std::getline(std::cin,email);
@ -41,4 +51,8 @@
+ } + }
} }
if (email.empty() || password.empty()) - if (email.empty() || password.empty())
+ if ((email.empty() || password.empty()) && !headless)
{
std::cerr << "Email and/or password empty" << std::endl;
return 0;