From fdcb96e25eb7c98a584c79fdad168596d6d24fb8 Mon Sep 17 00:00:00 2001 From: Markus Date: Sat, 17 Aug 2019 14:04:53 +0200 Subject: [PATCH] check for existing dir at cookieFile --- parameterManager.cpp | 3 +-- programManager.cpp | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/parameterManager.cpp b/parameterManager.cpp index d261cf8..875fd3b 100644 --- a/parameterManager.cpp +++ b/parameterManager.cpp @@ -743,9 +743,8 @@ void unterOption_clean(Settings * settings, int argc, char **argv) if(remove(settings->cookieFilePath.c_str()) != 0) { std::cout << "Das löschen von " << settings->cookieFilePath << " ist fehlgeschlagen: " << errno << std::endl; return; - } else { + } else count++; - } } for (unsigned i = 0; i < UINT_MAX && fileExists(settings->cookieFilePath + std::to_string(i)); i++) { diff --git a/programManager.cpp b/programManager.cpp index 03ac582..1b8ce9b 100644 --- a/programManager.cpp +++ b/programManager.cpp @@ -19,8 +19,13 @@ ProgramManager::~ProgramManager() int ProgramManager::start(Settings *settings) { pageManager.setProxy(settings->proxy_ip, settings->proxy_port); - pageManager.setCookieFilePath(settings->cookieFilePath); pageManager.setDebugMode(settings->debugMode); + pageManager.setCookieFilePath(settings->cookieFilePath); + if(dirExists(settings->cookieFilePath)) { + std::cout << " => Error: Kann Cokkie-File nicht erstellen: Es existiert bereits ein Ordner mit diesem Namen: \n '" + << settings->cookieFilePath << "'." << std::endl; + return 174; + } switch (settings->modus) { case Modus::DEFAULT_MODUS: @@ -42,8 +47,8 @@ void * threadFunction(void * KA) { myka->exitState=0; - - Reply tmp_reply = myka->pageManager->getServerRequest(myka->pageManager->UrlPraefix + myka->nameInUrl + "/staffel-" + std::to_string(myka->staffel) + "/episode-" + std::to_string(myka->folge)); + Reply tmp_reply = myka->pageManager->getServerRequest(myka->pageManager->UrlPraefix + myka->nameInUrl + + "/staffel-" + std::to_string(myka->staffel) + "/episode-" + std::to_string(myka->folge)); if(tmp_reply.html == "-1") return myka->setState(10); std::string allLinks = myka->pageManager->getLinks(tmp_reply.html); @@ -168,6 +173,11 @@ int ProgramManager::defaultModus(Settings *settings) if(settings->maxThreads > 0) { for (unsigned i = 0; i < settings->maxThreads; ++i) { + if(dirExists(settings->cookieFilePath + std::to_string( i ))) { + std::cout << " => Error: Kann Cokkie-File nicht erstellen: Es existiert bereits ein Ordner mit diesem Namen: \n '" + << settings->cookieFilePath + std::to_string( i ) << "'." << std::endl; + return 174; + } PageManager * pm = new PageManager("socks5://" + settings->proxy_ip + ":" + std::to_string(settings->proxy_port), settings->cookieFilePath + std::to_string( i )); pm->setDebugMode(settings->debugMode);