Skip to content

Commit 7aab433

Browse files
authored
Merge pull request #36 from FAIRDataPipeline/dev
fix script and config locations
2 parents ee7cf82 + eef5197 commit 7aab433

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ ENDIF()
2424

2525
# Define Project
2626
PROJECT( fdpapi
27-
VERSION 0.2.6
27+
VERSION 0.2.7
2828
DESCRIPTION "C++ API for the FAIR Data Pipeline"
2929
HOMEPAGE_URL "https://github.com/FAIRDataPipeline/cppDataPipeline"
3030
LANGUAGES CXX C

src/objects/config.cxx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,14 @@ void FairDataPipeline::Config::initialise(RESTAPI api_location) {
240240

241241
// Remove the Write Data Store from config file path
242242
Json::Value config_storage_location_value_;
243-
if(config_file_path_.string().find(meta_data_()["write_data_store"].as<std::string>()) !=std::string::npos){
244-
config_storage_location_value_["path"] = config_file_path_.string().replace(
245-
config_file_path_.string().find(meta_data_()["write_data_store"].as<std::string>()),
246-
sizeof(meta_data_()["write_data_store"].as<std::string>()) - 1, "");
247-
}
248-
else {
249-
config_storage_location_value_["path"] = config_file_path_.string();
243+
config_storage_location_value_["path"] = config_file_path_.string();
244+
std::size_t ind = config_file_path_.string().find(meta_data_()["write_data_store"].as<std::string>());
245+
if(ind != std::string::npos){
246+
config_storage_location_value_["path"] = config_storage_location_value_["path"].asString().erase(
247+
ind, meta_data_()["write_data_store"].as<std::string>().length()
248+
);
250249
}
250+
251251
config_storage_location_value_["path"] = remove_backslash_from_path(config_storage_location_value_["path"].asString());
252252
config_storage_location_value_["path"] = API::remove_leading_forward_slash(config_storage_location_value_["path"].asString());
253253
config_storage_location_value_["public"] = true;
@@ -280,16 +280,15 @@ void FairDataPipeline::Config::initialise(RESTAPI api_location) {
280280

281281
this->config_obj_ = ApiObject::from_json( j_config_obj );
282282

283-
Json::Value script_storage_location_value_;
284-
285-
if(script_file_path_.string().find(meta_data_()["write_data_store"].as<std::string>()) !=std::string::npos){
286-
script_storage_location_value_["path"] = script_file_path_.string().replace(
287-
script_file_path_.string().find(meta_data_()["write_data_store"].as<std::string>()),
288-
sizeof(meta_data_()["write_data_store"].as<std::string>()) - 1, "");
289-
}
290-
else {
291-
script_storage_location_value_["path"] = script_file_path_.string();
283+
Json::Value script_storage_location_value_;
284+
script_storage_location_value_["path"] = script_file_path_.string();
285+
ind = script_file_path_.string().find(meta_data_()["write_data_store"].as<std::string>());
286+
if(ind != std::string::npos){
287+
script_storage_location_value_["path"] = script_storage_location_value_["path"].asString().erase(
288+
ind, meta_data_()["write_data_store"].as<std::string>().length()
289+
);
292290
}
291+
293292
script_storage_location_value_["path"] = remove_backslash_from_path(script_storage_location_value_["path"].asString());
294293
script_storage_location_value_["path"] = API::remove_leading_forward_slash(script_storage_location_value_["path"].asString());
295294
script_storage_location_value_["hash"] = calculate_hash_from_file(script_file_path_);

0 commit comments

Comments
 (0)