Fix saving config when init fails but --login was not used

This commit is contained in:
Sude 2014-07-07 15:57:07 +03:00
parent 92b8ef3750
commit 31c547be8a
3 changed files with 6 additions and 6 deletions

View File

@ -44,6 +44,7 @@ class Downloader
Downloader(Config &conf); Downloader(Config &conf);
virtual ~Downloader(); virtual ~Downloader();
int init(); int init();
int login();
void listGames(); void listGames();
void updateCheck(); void updateCheck();
void repair(); void repair();
@ -59,7 +60,6 @@ class Downloader
CURLcode downloadFile(const std::string& url, const std::string& filepath, const std::string& xml_data = std::string(), const std::string& gamename = std::string()); CURLcode downloadFile(const std::string& url, const std::string& filepath, const std::string& xml_data = std::string(), const std::string& gamename = std::string());
int repairFile(const std::string& url, const std::string& filepath, const std::string& xml_data = std::string(), const std::string& gamename = std::string()); int repairFile(const std::string& url, const std::string& filepath, const std::string& xml_data = std::string(), const std::string& gamename = std::string());
int downloadCovers(const std::string& gamename, const std::string& directory, const std::string& cover_xml_data); int downloadCovers(const std::string& gamename, const std::string& directory, const std::string& cover_xml_data);
int login();
int getGameDetails(); int getGameDetails();
void getGameList(); void getGameList();
size_t getResumePosition(); size_t getResumePosition();

View File

@ -291,12 +291,12 @@ int main(int argc, char *argv[])
config.sDirectory += "/"; config.sDirectory += "/";
Downloader downloader(config); Downloader downloader(config);
int result = downloader.init(); int initResult = downloader.init();
int iLoginResult = 0; int iLoginResult = 0;
if (config.bLogin) if (config.bLogin || initResult == 1)
{ {
iLoginResult = result; iLoginResult = downloader.login();
if (iLoginResult == 0) if (iLoginResult == 0)
return 1; return 1;
} }

View File

@ -79,8 +79,8 @@ int Downloader::init()
progressbar = new ProgressBar(config.bUnicode, config.bColor); progressbar = new ProgressBar(config.bUnicode, config.bColor);
bool bInitOK = gogAPI->init(); // Initialize the API bool bInitOK = gogAPI->init(); // Initialize the API
if (config.bLogin || !bInitOK) if (!bInitOK)
return this->login(); return 1;
if (config.bCover && config.bDownload && !config.bUpdateCheck) if (config.bCover && config.bDownload && !config.bUpdateCheck)
coverXML = this->getResponse("https://sites.google.com/site/gogdownloader/covers.xml"); coverXML = this->getResponse("https://sites.google.com/site/gogdownloader/covers.xml");