diff --git a/src/nopayloadclient.cpp b/src/nopayloadclient.cpp index 03bc6ae..3adbef4 100644 --- a/src/nopayloadclient.cpp +++ b/src/nopayloadclient.cpp @@ -262,12 +262,14 @@ json NoPayloadClient::makeResp(T msg) { return {{"code", 0}, {"msg", msg}}; } +template json NoPayloadClient::makeResp(json); + // Private void NoPayloadClient::insertPayload(Payload &pl, IOV &iov) { prepareInsertIov(pl); pl_handler_.prepareUploadFile(pl); - insertIov(pl, iov); pl_handler_.uploadFile(pl); + insertIov(pl, iov); } void NoPayloadClient::prepareInsertIov(Payload &pl) { diff --git a/src/plhandler.cpp b/src/plhandler.cpp index 9902e96..4576e35 100644 --- a/src/plhandler.cpp +++ b/src/plhandler.cpp @@ -73,7 +73,12 @@ void PLHandler::checkRemoteDirExists() { void PLHandler::createDirectory(const string& path){ if (!fs::is_directory(path) || !fs::exists(path)) { - fs::create_directories(path); + try{ + fs::create_directories(path); + } + catch(...){ + throw BaseException("remote payload directory "+path+" could not be created"); + } } } @@ -85,7 +90,10 @@ void PLHandler::prepareUploadFile(const Payload& pl) { void PLHandler::copyFile(const string& local_url, const string& remote_url) { if (!fs::exists(remote_url)) { - fs::copy_file(local_url, remote_url); + if (! fs::copy_file(local_url, remote_url)) + { + throw BaseException("could not copy "+local_url+" to "+remote_url); + } } } diff --git a/src/realwrapper.cpp b/src/realwrapper.cpp index 5eea53d..d4948f7 100644 --- a/src/realwrapper.cpp +++ b/src/realwrapper.cpp @@ -1,6 +1,7 @@ #include #include +#include namespace nopayloadclient { @@ -13,8 +14,9 @@ RealWrapper::RealWrapper(const json& config) { } void RealWrapper::sleep(int retry_number) { - srand(time(0)); - int n_sleep = rand()%(retry_sleep_mean_*2)+1; // add random sleep + std::random_device rd; + std::uniform_int_distribution dist(1, retry_sleep_mean_*2); + int n_sleep = dist(rd); // add random sleep logging::debug("sleeping for " + std::to_string(n_sleep) + " seconds before retrying..."); std::this_thread::sleep_for(std::chrono::seconds(n_sleep)); }