Skip to content

Commit 699feec

Browse files
pillotdavidrohr
authored andcommitted
add protection against missing object
1 parent adea3ba commit 699feec

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Detectors/MUON/MCH/Conditions/src/bad-channels-ccdb.cxx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ std::set<uint64_t> listTSWhenBadChannelsChange(const std::string ccdbUrl, const
100100
std::string currentETag{};
101101
for (auto itTS = tsChanges.begin(); itTS != tsChanges.end();) {
102102
auto headers = api.retrieveHeaders(source, metadata, *itTS);
103-
if (headers["ETag"] == currentETag) {
103+
if (headers["ETag"].empty()) {
104+
std::cout << "- Warning: missing file" << std::endl;
105+
auto validUntil = (std::next(itTS) != tsChanges.end()) ? *std::next(itTS) : endTimestamp;
106+
std::cout << fmt::format(" validity range: {} - {}\n", *itTS, validUntil);
107+
++itTS;
108+
} else if (headers["ETag"] == currentETag) {
104109
itTS = tsChanges.erase(itTS);
105110
} else {
106111
if (verbose) {
@@ -129,6 +134,19 @@ BadChannelsVector queryBadChannels(const std::string ccdbUrl,
129134
std::map<std::string, std::string> metadata;
130135
auto source = ccdbPath(badChannelType);
131136
auto* badChannels = api.retrieveFromTFileAny<BadChannelsVector>(source, metadata, timestamp);
137+
if (badChannels == nullptr) {
138+
std::cout << "do you want to proceed anyway? [y/n] ";
139+
std::string response{};
140+
while (true) {
141+
std::cin >> response;
142+
if (response == "y") {
143+
std::cout << "number of bad channels = 0" << std::endl;
144+
return {};
145+
} else if (response == "n") {
146+
exit(3);
147+
}
148+
}
149+
}
132150
std::cout << "number of bad channels = " << badChannels->size() << std::endl;
133151
if (verbose) {
134152
for (const auto& badChannel : *badChannels) {

0 commit comments

Comments
 (0)