Skip to content

Commit a58f6f5

Browse files
committed
Add check on downloaded file
1 parent e57ad30 commit a58f6f5

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

ALICE3/Core/DelphesO2TrackSmearer.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload)
6464
return false;
6565
}
6666

67-
filename = o2::fastsim::GeometryEntry::accessFile(filename, "./ALICE3/LUTs/", mCcdbManager, 600).c_str();
67+
filename = o2::fastsim::GeometryEntry::accessFile(filename, "./.ALICE3/LUTs/", mCcdbManager).c_str();
6868
mLUTHeader[ipdg] = new lutHeader_t;
6969

7070
std::ifstream lutFile(filename, std::ifstream::binary);

ALICE3/Core/GeometryContainer.cxx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,24 @@ std::string GeometryEntry::accessFile(const std::string& path, const std::string
218218
// File does not exist, retrieve from CCDB
219219
LOG(info) << " --- CCDB source detected for detector geometry " << path;
220220
std::map<std::string, std::string> metadata;
221-
ccdb->getCCDBAccessor().retrieveBlob(ccdbPath, localPath, metadata, 1);
221+
ccdb->getCCDBAccessor().retrieveBlob(ccdbPath, downloadPath, metadata, 1);
222222
LOG(info) << " --- Retrieved geometry configuration from CCDB to: " << localPath;
223223

224+
// Verify the integrity of the downloaded file
225+
if (stat(localPath.c_str(), &buffer) != 0) {
226+
flock(lockFd, LOCK_UN);
227+
close(lockFd);
228+
LOG(fatal) << " --- Downloaded file does not exist or is not accessible: " << localPath;
229+
return "";
230+
}
231+
if (buffer.st_size == 0) {
232+
flock(lockFd, LOCK_UN);
233+
close(lockFd);
234+
LOG(fatal) << " --- Downloaded file is empty: " << localPath;
235+
return "";
236+
}
237+
LOG(info) << " --- File integrity verified. Size: " << buffer.st_size << " bytes";
238+
224239
// Create done marker file to indicate successful download
225240
std::ofstream doneMarker(doneFile);
226241
doneMarker.close();

0 commit comments

Comments
 (0)