Skip to content

Commit 60fcabf

Browse files
shahor02Barthelemy
authored andcommitted
Fix for headers-only CCDB uploads
1 parent 50c4217 commit 60fcabf

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

CCDB/src/CcdbApi.cxx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,10 @@ int CcdbApi::storeAsBinaryFile(const char* buffer, size_t size, const std::strin
369369
sanitizedEndValidityTimestamp = getFutureTimestamp(60 * 60 * 24 * 1);
370370
}
371371
if (mInSnapshotMode) { // write local file
372+
if (filename.empty() || buffer == nullptr || size == 0) {
373+
LOGP(alarm, "Snapshot mode does not support headers-only upload");
374+
return -3;
375+
}
372376
auto pthLoc = getSnapshotDir(mSnapshotTopPath, path);
373377
o2::utils::createDirectoriesIfAbsent(pthLoc);
374378
auto flLoc = getSnapshotFile(mSnapshotTopPath, path, filename);
@@ -412,8 +416,14 @@ int CcdbApi::storeAsBinaryFile(const char* buffer, size_t size, const std::strin
412416
auto mime = curl_mime_init(curl);
413417
auto field = curl_mime_addpart(mime);
414418
curl_mime_name(field, "send");
415-
curl_mime_filedata(field, filename.c_str());
416-
curl_mime_data(field, buffer, size);
419+
if (filename.empty()) {
420+
curl_mime_filedata(field, filename.c_str());
421+
}
422+
if (buffer != nullptr && size > 0) {
423+
curl_mime_data(field, buffer, size);
424+
} else {
425+
curl_mime_data(field, "", 0);
426+
}
417427

418428
struct curl_slist* headerlist = nullptr;
419429
static const char buf[] = "Expect:";

CCDB/src/UploadTool.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ int main(int argc, char* argv[])
148148
}
149149

150150
if (filename == "headersOnly") {
151+
auto ent = meta.find("Redirect");
152+
std::cout << " Uploading a headers-only object to path " << path << " with timestamp validity from " << starttimestamp << " to " << endtimestamp
153+
<< " Redirection to: " << ((ent != meta.end()) ? ent->second : std::string{"none"}) << "\n";
151154
api.storeAsBinaryFile(nullptr, 0, "ignored", "", path, meta, starttimestamp, endtimestamp);
152155
if (!api.isSnapshotMode() && meta.find("adjustableEOV") != meta.end() && meta.find("default") == meta.end()) {
153156
o2::ccdb::CcdbObjectInfo oi(path, "", "", meta, starttimestamp, endtimestamp);

0 commit comments

Comments
 (0)