Bug fixing

This commit is contained in:
Your Name
2025-05-25 13:11:13 +12:00
parent 7b3706ebf5
commit f1d6fe661a
5 changed files with 37 additions and 39 deletions

View File

@@ -236,10 +236,10 @@ void Server::handle_get_object(const httplib::Request& req, httplib::Response& r
}
void Server::handle_get_hash(const httplib::Request& req, httplib::Response& res) {
const auto& label_tag = req.matches[1].str();
const auto& labeltag = req.matches[1].str();
dbEntry entry;
if (!db_->get(label_tag, entry)) {
if (!db_->get(labeltag, entry)) {
res.status = 404;
nlohmann::json response = {{"result", "error"}, {"error", "Label:tag not found"}};
res.set_content(response.dump(), "application/json");
@@ -262,10 +262,8 @@ void Server::handle_get_directory(const httplib::Request& /*req*/, httplib::Resp
nlohmann::json entries_array = nlohmann::json::array();
for (const auto& entry : entries) {
for (const auto & label : entry.labels) {
for (const auto & tag : entry.tags) {
entries_array.push_back({{"label_tag", label + ":" + tag}, {"hash", entry.hash}});
}
for (const auto & labeltag : entry.labeltags) {
entries_array.push_back({{"labeltag", labeltag}, {"hash", entry.hash}});
}
}
@@ -344,12 +342,12 @@ void Server::handle_get_metadata(const httplib::Request& req, httplib::Response&
res.set_content(response.dump(), "application/json");
}
std::pair<std::string, std::string> Server::parse_label_tag(const std::string& label_tag) const {
size_t colon_pos = label_tag.find(':');
if (colon_pos == std::string::npos || colon_pos == 0 || colon_pos == label_tag.length() - 1) {
std::pair<std::string, std::string> Server::parse_labeltag(const std::string& labeltag) const {
size_t colon_pos = labeltag.find(':');
if (colon_pos == std::string::npos || colon_pos == 0 || colon_pos == labeltag.length() - 1) {
return {"", ""};
}
return {label_tag.substr(0, colon_pos), label_tag.substr(colon_pos + 1)};
return {labeltag.substr(0, colon_pos), labeltag.substr(colon_pos + 1)};
}
void Server::handle_delete_object(const httplib::Request& req, httplib::Response& res) {