mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2024-11-20 11:49:17 +01:00
Slightly nicer libcurl cleanup
This commit is contained in:
parent
ed41fbef6f
commit
4fcb3bceb7
10
main.cpp
10
main.cpp
@ -635,6 +635,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Init curl globally
|
// Init curl globally
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
|
struct CurlCleanup { ~CurlCleanup() { curl_global_cleanup(); } };
|
||||||
|
CurlCleanup _curl_cleanup;
|
||||||
|
|
||||||
Downloader downloader;
|
Downloader downloader;
|
||||||
|
|
||||||
@ -662,7 +664,6 @@ int main(int argc, char *argv[])
|
|||||||
// Login failed, cleanup
|
// Login failed, cleanup
|
||||||
if (!bLoginOK && !bIsLoggedin)
|
if (!bLoginOK && !bIsLoggedin)
|
||||||
{
|
{
|
||||||
curl_global_cleanup();
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -725,14 +726,12 @@ int main(int argc, char *argv[])
|
|||||||
Util::setFilePermissions(Globals::globalConfig.sConfigFilePath, boost::filesystem::owner_read | boost::filesystem::owner_write);
|
Util::setFilePermissions(Globals::globalConfig.sConfigFilePath, boost::filesystem::owner_read | boost::filesystem::owner_write);
|
||||||
if (Globals::globalConfig.bSaveConfig)
|
if (Globals::globalConfig.bSaveConfig)
|
||||||
{
|
{
|
||||||
curl_global_cleanup();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to create config: " << Globals::globalConfig.sConfigFilePath << std::endl;
|
std::cerr << "Failed to create config: " << Globals::globalConfig.sConfigFilePath << std::endl;
|
||||||
curl_global_cleanup();
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -745,13 +744,11 @@ int main(int argc, char *argv[])
|
|||||||
if (!Globals::globalConfig.bRespectUmask)
|
if (!Globals::globalConfig.bRespectUmask)
|
||||||
Util::setFilePermissions(Globals::globalConfig.sConfigFilePath, boost::filesystem::owner_read | boost::filesystem::owner_write);
|
Util::setFilePermissions(Globals::globalConfig.sConfigFilePath, boost::filesystem::owner_read | boost::filesystem::owner_write);
|
||||||
|
|
||||||
curl_global_cleanup();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to create config: " << Globals::globalConfig.sConfigFilePath << std::endl;
|
std::cerr << "Failed to create config: " << Globals::globalConfig.sConfigFilePath << std::endl;
|
||||||
curl_global_cleanup();
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -759,7 +756,6 @@ int main(int argc, char *argv[])
|
|||||||
bool bInitOK = downloader.init();
|
bool bInitOK = downloader.init();
|
||||||
if (!bInitOK)
|
if (!bInitOK)
|
||||||
{
|
{
|
||||||
curl_global_cleanup();
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -881,7 +877,5 @@ int main(int argc, char *argv[])
|
|||||||
if (!Globals::globalConfig.sOrphanRegex.empty() && Globals::globalConfig.bDownload)
|
if (!Globals::globalConfig.sOrphanRegex.empty() && Globals::globalConfig.bDownload)
|
||||||
downloader.checkOrphans();
|
downloader.checkOrphans();
|
||||||
|
|
||||||
curl_global_cleanup();
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user