Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/nopayloadclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ json NoPayloadClient::makeResp(T msg) {
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) {
Expand Down
12 changes: 10 additions & 2 deletions src/plhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}

Expand All @@ -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);
}
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/realwrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <nopayloadclient/realwrapper.hpp>

#include <cstdlib>

namespace nopayloadclient {

RealWrapper::RealWrapper(const json& config) {
Expand All @@ -10,7 +12,8 @@ RealWrapper::RealWrapper(const json& config) {
}

void RealWrapper::sleep(int retry_number) {
int n_sleep = int(std::exp(retry_number));
srand(time(0));
int n_sleep = rand()%100+1; // add random sleep 1-100 secs
logging::debug("sleeping for " + std::to_string(n_sleep) + " seconds before retrying...");
std::this_thread::sleep_for(std::chrono::seconds(n_sleep));
}
Expand Down Expand Up @@ -69,4 +72,4 @@ json CurlRequest::parseResponse() {
return response;
}

}
}