mirror of https://github.com/vitalif/grive2
Prevent the user from sending a SIGINT while downloading a file..
parent
95133eff57
commit
2791bbbfe8
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include "Download.hh"
|
||||
#include "../util/SignalHandler.hh"
|
||||
|
||||
#include <openssl/evp.h>
|
||||
|
||||
|
@ -57,6 +58,9 @@ Download::~Download( )
|
|||
|
||||
std::string Download::Finish() const
|
||||
{
|
||||
// Unregister the signal
|
||||
SignalHandler::GetInstance().UnregisterSignal( SIGINT ) ;
|
||||
|
||||
std::string result ;
|
||||
|
||||
// get the checksum and return it ;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "HTTP.hh"
|
||||
|
||||
#include "Download.hh"
|
||||
#include "../util/SignalHandler.hh"
|
||||
|
||||
// dependent libraries
|
||||
#include <curl/curl.h>
|
||||
|
@ -109,6 +110,14 @@ void DoCurl( CURL *curl )
|
|||
}
|
||||
}
|
||||
|
||||
// Callback for SIGINT
|
||||
void CallbackInt( int )
|
||||
{
|
||||
// TODO: instead of just disabling the signal, clean up the environment
|
||||
// and exit gracefully
|
||||
std::cout << " Signal disabled while downloading file..\n";
|
||||
}
|
||||
|
||||
} // end of local namespace
|
||||
|
||||
namespace gr { namespace http {
|
||||
|
@ -139,6 +148,9 @@ void GetFile(
|
|||
const std::string& filename,
|
||||
const Headers& hdr )
|
||||
{
|
||||
// Register the callback
|
||||
SignalHandler::GetInstance().RegisterSignal( SIGINT, &CallbackInt ) ;
|
||||
|
||||
Download dl( filename, Download::NoChecksum() ) ;
|
||||
|
||||
CURL *curl = InitCurl( url, 0, hdr ) ;
|
||||
|
|
Loading…
Reference in New Issue