Skip to content

Commit 64169ca

Browse files
authored
Merge pull request #511 from rest-for-physics/lobis-download
Add option to PID prefix on downloads to avoid faults
2 parents ee19195 + 33cc009 commit 64169ca

4 files changed

Lines changed: 12 additions & 6 deletions

File tree

source/framework/core/src/TRestEvent.cxx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949

5050
#include "TRestEvent.h"
5151

52+
#include "TRestRun.h"
53+
5254
using namespace std;
5355

5456
ClassImp(TRestEvent);
@@ -170,7 +172,11 @@ void TRestEvent::RestartPad(Int_t nElements) {
170172

171173
void TRestEvent::InitializeWithMetadata(TRestRun* run) { Initialize(); }
172174

173-
void TRestEvent::InitializeReferences(TRestRun* run) { fRun = run; }
175+
void TRestEvent::InitializeReferences(TRestRun* run) {
176+
fRun = run;
177+
SetRunOrigin(fRun->GetRunNumber());
178+
SetSubRunOrigin(fRun->GetSubRunNumber());
179+
}
174180

175181
//////////////////////////////////////////////////////////////////////////
176182
/// Run to print event data info on console

source/framework/core/src/TRestMetadata.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ void TRestMetadata::ExpandIncludeFile(TiXmlElement* e) {
12841284
url = _filename;
12851285
}
12861286

1287-
filename = TRestTools::DownloadRemoteFile(url);
1287+
filename = TRestTools::DownloadRemoteFile(url, true);
12881288
} else {
12891289
filename = SearchFile(_filename);
12901290
}

source/framework/tools/inc/TRestTools.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class TRestTools {
127127

128128
static std::string Execute(std::string cmd);
129129

130-
static std::string DownloadRemoteFile(const std::string& remoteFile);
130+
static std::string DownloadRemoteFile(const std::string& remoteFile, bool pidPrefix = false);
131131
static int DownloadRemoteFile(std::string remoteFile, std::string localFile);
132132
static int UploadToServer(std::string localFile, std::string remoteFile, std::string methodUrl = "");
133133

source/framework/tools/src/TRestTools.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ std::istream& TRestTools::GetLine(std::istream& is, std::string& t) {
11211121
/// will be used, including scp, wget. Downloads to REST_USER_PATH + "/download/" + filename
11221122
/// by default.
11231123
///
1124-
std::string TRestTools::DownloadRemoteFile(const string& url) {
1124+
std::string TRestTools::DownloadRemoteFile(const string& url, bool pidPrefix) {
11251125
string pureName = TRestTools::GetPureFileName(url);
11261126
if (pureName.empty()) {
11271127
RESTWarning << "error! (TRestTools::DownloadRemoteFile): url is not a file!" << RESTendl;
@@ -1133,7 +1133,8 @@ std::string TRestTools::DownloadRemoteFile(const string& url) {
11331133
if (url.find("local:") == 0) {
11341134
return Replace(url, "local:", "");
11351135
} else {
1136-
string fullpath = REST_USER_PATH + "/download/" + pureName;
1136+
string fullpath =
1137+
REST_USER_PATH + "/download/" + (pidPrefix ? "PID_" + ToString(getpid()) + "_" : "") + pureName;
11371138
int out;
11381139
int attempts = 10;
11391140
do {
@@ -1153,7 +1154,6 @@ std::string TRestTools::DownloadRemoteFile(const string& url) {
11531154
return "";
11541155
}
11551156
}
1156-
return "";
11571157
}
11581158

11591159
///////////////////////////////////////////////

0 commit comments

Comments
 (0)