@@ -240,14 +240,14 @@ void FairDataPipeline::Config::initialise(RESTAPI api_location) {
240
240
241
241
// Remove the Write Data Store from config file path
242
242
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
+ );
250
249
}
250
+
251
251
config_storage_location_value_[" path" ] = remove_backslash_from_path (config_storage_location_value_[" path" ].asString ());
252
252
config_storage_location_value_[" path" ] = API::remove_leading_forward_slash (config_storage_location_value_[" path" ].asString ());
253
253
config_storage_location_value_[" public" ] = true ;
@@ -280,16 +280,15 @@ void FairDataPipeline::Config::initialise(RESTAPI api_location) {
280
280
281
281
this ->config_obj_ = ApiObject::from_json ( j_config_obj );
282
282
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
+ );
292
290
}
291
+
293
292
script_storage_location_value_[" path" ] = remove_backslash_from_path (script_storage_location_value_[" path" ].asString ());
294
293
script_storage_location_value_[" path" ] = API::remove_leading_forward_slash (script_storage_location_value_[" path" ].asString ());
295
294
script_storage_location_value_[" hash" ] = calculate_hash_from_file (script_file_path_);
0 commit comments