Skip to content

Commit 7b3397d

Browse files
committed
Fix for headers-only CCDB uploads
1 parent b6c63a0 commit 7b3397d

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
@@ -375,6 +375,10 @@ int CcdbApi::storeAsBinaryFile(const char* buffer, size_t size, const std::strin
375375
sanitizedEndValidityTimestamp = getFutureTimestamp(60 * 60 * 24 * 1);
376376
}
377377
if (mInSnapshotMode) { // write local file
378+
if (filename.empty() || buffer == nullptr || size == 0) {
379+
LOGP(alarm, "Snapshot mode does not support headers-only upload");
380+
return -3;
381+
}
378382
auto pthLoc = getSnapshotDir(mSnapshotTopPath, path);
379383
o2::utils::createDirectoriesIfAbsent(pthLoc);
380384
auto flLoc = getSnapshotFile(mSnapshotTopPath, path, filename);
@@ -418,8 +422,14 @@ int CcdbApi::storeAsBinaryFile(const char* buffer, size_t size, const std::strin
418422
auto mime = curl_mime_init(curl);
419423
auto field = curl_mime_addpart(mime);
420424
curl_mime_name(field, "send");
421-
curl_mime_filedata(field, filename.c_str());
422-
curl_mime_data(field, buffer, size);
425+
if (filename.empty()) {
426+
curl_mime_filedata(field, filename.c_str());
427+
}
428+
if (buffer != nullptr && size > 0) {
429+
curl_mime_data(field, buffer, size);
430+
} else {
431+
curl_mime_data(field, "", 0);
432+
}
423433

424434
struct curl_slist* headerlist = nullptr;
425435
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)