This commit is contained in:
@@ -18,6 +18,6 @@ jobs:
|
||||
./build.sh all
|
||||
- name: Build and Push amd64 + arm64 Docker image to the registry
|
||||
run: |
|
||||
./publish.sh
|
||||
./.gitea_runner/publish.sh
|
||||
|
||||
|
||||
|
@@ -5,7 +5,8 @@ set -e
|
||||
|
||||
# DIRECTORIES
|
||||
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
|
||||
function title() {
|
||||
@@ -29,7 +30,9 @@ function die() {
|
||||
#--------------------------------
|
||||
# MAIN
|
||||
#--------------------------------
|
||||
cd "$SCRIPT_DIR"
|
||||
PREV_DIR=$(pwd)
|
||||
|
||||
cd "$MAIN_DIR"
|
||||
|
||||
# build the executables
|
||||
./build.sh all
|
||||
@@ -58,4 +61,6 @@ docker buildx build --push -t gitea.jde.nz/public/simple-object-storage:latest -
|
||||
echo "Build completed successfully!"
|
||||
|
||||
# switch back to the default builder
|
||||
docker buildx use default
|
||||
docker buildx use default
|
||||
|
||||
cd "$PREV_DIR"
|
@@ -182,22 +182,13 @@ bool Database::remove_by_hash(const std::string& hash) {
|
||||
return success;
|
||||
}
|
||||
|
||||
bool Database::get(const std::string& hash_or_labeltag, 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 = ?;";
|
||||
}
|
||||
|
||||
bool Database::run_sql_text(const std::string& sql, const std::string& bind_text, dbEntry& entry) {
|
||||
sqlite3_stmt* stmt;
|
||||
if (sqlite3_prepare_v2(db_, sql.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
|
||||
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) {
|
||||
sqlite3_finalize(stmt);
|
||||
@@ -207,7 +198,7 @@ bool Database::get(const std::string& hash_or_labeltag, dbEntry& entry) {
|
||||
entry.hash = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 0));
|
||||
std::string labeltags_str = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 1));
|
||||
std::string metadata_str = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 2));
|
||||
|
||||
|
||||
entry.labeltags = nlohmann::json::parse(labeltags_str).get<std::vector<std::string>>();
|
||||
entry.metadata = nlohmann::json::parse(metadata_str);
|
||||
|
||||
@@ -215,6 +206,18 @@ bool Database::get(const std::string& hash_or_labeltag, dbEntry& entry) {
|
||||
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) {
|
||||
std::string sql = "SELECT hash, labeltags, metadata FROM objects;";
|
||||
sqlite3_stmt* stmt;
|
||||
|
@@ -40,6 +40,8 @@ class Database {
|
||||
bool merge_existing_entry(const dbEntry& existing, const dbEntry& new_entry, dbEntry& merged);
|
||||
bool insert_new_entry(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
|
||||
|
Reference in New Issue
Block a user