:-'Generic Commit'
Some checks failed
Build-Test-Publish / Build (push) Failing after 29s

This commit is contained in:
Your Name
2025-05-30 19:23:53 +12:00
parent b72eb9394a
commit 2c2517f2fc
4 changed files with 26 additions and 16 deletions

View File

@@ -18,6 +18,6 @@ jobs:
./build.sh all ./build.sh all
- name: Build and Push amd64 + arm64 Docker image to the registry - name: Build and Push amd64 + arm64 Docker image to the registry
run: | run: |
./publish.sh ./.gitea_runner/publish.sh

View File

@@ -5,7 +5,8 @@ set -e
# DIRECTORIES # DIRECTORIES
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
EXE_DIR="${SCRIPT_DIR}/output" MAIN_DIR=$(cd "${SCRIPT_DIR}/.." && pwd)
EXE_DIR="${MAIN_DIR}/output"
# FUNCTIONS # FUNCTIONS
function title() { function title() {
@@ -29,7 +30,9 @@ function die() {
#-------------------------------- #--------------------------------
# MAIN # MAIN
#-------------------------------- #--------------------------------
cd "$SCRIPT_DIR" PREV_DIR=$(pwd)
cd "$MAIN_DIR"
# build the executables # build the executables
./build.sh all ./build.sh all
@@ -59,3 +62,5 @@ echo "Build completed successfully!"
# switch back to the default builder # switch back to the default builder
docker buildx use default docker buildx use default
cd "$PREV_DIR"

View File

@@ -182,22 +182,13 @@ bool Database::remove_by_hash(const std::string& hash) {
return success; return success;
} }
bool Database::get(const std::string& hash_or_labeltag, dbEntry& entry) { bool Database::run_sql_text(const std::string& sql, const std::string& bind_text, dbEntry& entry) {
std::string sql;
if (hash_or_labeltag.find(':') != std::string::npos) {
// Query by label:tag - search for exact match in the JSON array
sql = "SELECT hash, labeltags, metadata FROM objects WHERE json_array_length(labeltags) > 0 AND EXISTS (SELECT 1 FROM json_each(labeltags) WHERE value = ?);";
} else {
// Query by hash
sql = "SELECT hash, labeltags, metadata FROM objects WHERE hash = ?;";
}
sqlite3_stmt* stmt; sqlite3_stmt* stmt;
if (sqlite3_prepare_v2(db_, sql.c_str(), -1, &stmt, nullptr) != SQLITE_OK) { if (sqlite3_prepare_v2(db_, sql.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
return false; return false;
} }
sqlite3_bind_text(stmt, 1, hash_or_labeltag.c_str(), -1, SQLITE_STATIC); sqlite3_bind_text(stmt, 1, bind_text.c_str(), -1, SQLITE_STATIC);
if (sqlite3_step(stmt) != SQLITE_ROW) { if (sqlite3_step(stmt) != SQLITE_ROW) {
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
@@ -215,6 +206,18 @@ bool Database::get(const std::string& hash_or_labeltag, dbEntry& entry) {
return true; return true;
} }
bool Database::get(const std::string& hash_or_labeltag, dbEntry& entry) {
if (hash_or_labeltag.find(':') != std::string::npos)
return (run_sql_text("SELECT hash, labeltags, metadata FROM objects WHERE json_array_length(labeltags) > 0 AND EXISTS (SELECT 1 FROM json_each(labeltags) WHERE value = ?);", hash_or_labeltag, entry));
if (run_sql_text("SELECT hash, labeltags, metadata FROM objects WHERE hash = ?;", hash_or_labeltag, entry))
return true;
std::string with_latest = hash_or_labeltag + ":latest";
return (run_sql_text("SELECT hash, labeltags, metadata FROM objects WHERE hash = ?;", with_latest, entry));
}
bool Database::list(std::vector<dbEntry>& entries) { bool Database::list(std::vector<dbEntry>& entries) {
std::string sql = "SELECT hash, labeltags, metadata FROM objects;"; std::string sql = "SELECT hash, labeltags, metadata FROM objects;";
sqlite3_stmt* stmt; sqlite3_stmt* stmt;

View File

@@ -40,6 +40,8 @@ class Database {
bool merge_existing_entry(const dbEntry& existing, const dbEntry& new_entry, dbEntry& merged); bool merge_existing_entry(const dbEntry& existing, const dbEntry& new_entry, dbEntry& merged);
bool insert_new_entry(const dbEntry& entry); bool insert_new_entry(const dbEntry& entry);
bool handle_tag_conflicts(const dbEntry& entry); bool handle_tag_conflicts(const dbEntry& entry);
bool run_sql_text(const std::string& sql, const std::string& bind_text, dbEntry& entry);
}; };
} // namespace simple_object_storage } // namespace simple_object_storage