check for existing dir at cookieFile

This commit is contained in:
Markus 2019-08-17 14:04:53 +02:00
parent 5fcd1fcce1
commit fdcb96e25e
2 changed files with 14 additions and 5 deletions

View File

@ -743,9 +743,8 @@ void unterOption_clean(Settings * settings, int argc, char **argv)
if(remove(settings->cookieFilePath.c_str()) != 0) { if(remove(settings->cookieFilePath.c_str()) != 0) {
std::cout << "Das löschen von " << settings->cookieFilePath << " ist fehlgeschlagen: " << errno << std::endl; std::cout << "Das löschen von " << settings->cookieFilePath << " ist fehlgeschlagen: " << errno << std::endl;
return; return;
} else { } else
count++; count++;
}
} }


for (unsigned i = 0; i < UINT_MAX && fileExists(settings->cookieFilePath + std::to_string(i)); i++) { for (unsigned i = 0; i < UINT_MAX && fileExists(settings->cookieFilePath + std::to_string(i)); i++) {

View File

@ -19,8 +19,13 @@ ProgramManager::~ProgramManager()
int ProgramManager::start(Settings *settings) int ProgramManager::start(Settings *settings)
{ {
pageManager.setProxy(settings->proxy_ip, settings->proxy_port); pageManager.setProxy(settings->proxy_ip, settings->proxy_port);
pageManager.setCookieFilePath(settings->cookieFilePath);
pageManager.setDebugMode(settings->debugMode); 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) { switch (settings->modus) {
case Modus::DEFAULT_MODUS: case Modus::DEFAULT_MODUS:
@ -42,8 +47,8 @@ void * threadFunction(void * KA) {
myka->exitState=0; myka->exitState=0;





Reply tmp_reply = myka->pageManager->getServerRequest(myka->pageManager->UrlPraefix + myka->nameInUrl
Reply tmp_reply = myka->pageManager->getServerRequest(myka->pageManager->UrlPraefix + myka->nameInUrl + "/staffel-" + std::to_string(myka->staffel) + "/episode-" + std::to_string(myka->folge)); + "/staffel-" + std::to_string(myka->staffel) + "/episode-" + std::to_string(myka->folge));
if(tmp_reply.html == "-1") if(tmp_reply.html == "-1")
return myka->setState(10); return myka->setState(10);
std::string allLinks = myka->pageManager->getLinks(tmp_reply.html); std::string allLinks = myka->pageManager->getLinks(tmp_reply.html);
@ -168,6 +173,11 @@ int ProgramManager::defaultModus(Settings *settings)


if(settings->maxThreads > 0) { if(settings->maxThreads > 0) {
for (unsigned i = 0; i < settings->maxThreads; ++i) { 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 )); PageManager * pm = new PageManager("socks5://" + settings->proxy_ip + ":" + std::to_string(settings->proxy_port), settings->cookieFilePath + std::to_string( i ));
pm->setDebugMode(settings->debugMode); pm->setDebugMode(settings->debugMode);