Bug fixing

This commit is contained in:
Your Name
2025-05-25 13:21:59 +12:00
parent aef2f84ed7
commit 3ad9fc2afa
2 changed files with 17 additions and 15 deletions

View File

@@ -33,6 +33,14 @@ function die() {
#-------------------------------- #--------------------------------
cd $SCRIPT_DIR cd $SCRIPT_DIR
# build the executables
./build.sh
# build the Docker image
./build-docker.sh
# push the Docker image to the registry
if [ ! -f ${EXE_DIR}/simple_object_storage-linux-x86_64 ]; then if [ ! -f ${EXE_DIR}/simple_object_storage-linux-x86_64 ]; then
die "x86_64 executable not found" die "x86_64 executable not found"
fi fi
@@ -41,24 +49,19 @@ if [ ! -f ${EXE_DIR}/simple_object_storage-linux-arm64 ]; then
die "arm64 executable not found" die "arm64 executable not found"
fi fi
# build the executables.
./build.sh
# use Docker architecture style # use Docker architecture style
cp ${EXE_DIR}/simple_object_storage-linux-x86_64 ${EXE_DIR}/simple_object_storage-linux-amd64 cp ${EXE_DIR}/simple_object_storage-linux-x86_64 ${EXE_DIR}/simple_object_storage-linux-amd64
echo "amd64 executable: ./simple_object_storage-linux-amd64" echo "amd64 executable: ./simple_object_storage-linux-amd64"
echo "arm64 executable: ./simple_object_storage-linux-arm64" echo "arm64 executable: ./simple_object_storage-linux-arm64"
echo "Setting up Docker BuildX builder 'sosbuilder'"
# Check if builder instance exists
if ! docker buildx inspect sosbuilder > /dev/null 2>&1; then
echo "Builder 'sosbuilder' not found, creating..."
docker buildx create --name sosbuilder
else
echo "Builder 'sosbuilder' already exists."
fi
# Ensure the builder is used
docker buildx use sosbuilder
echo "Building multi-platform Docker image" echo "Building multi-platform Docker image"
docker buildx build --push -t gitea.jde.nz/public/simple-object-storage:latest --platform linux/amd64,linux/arm64 . docker buildx build --push -t gitea.jde.nz/public/simple-object-storage:latest --platform linux/amd64,linux/arm64 .
rm ${EXE_DIR}/simple_object_storage-linux-amd64
echo "Build completed successfully!" echo "Build completed successfully!"

View File

@@ -185,8 +185,8 @@ bool Database::remove_by_hash(const std::string& hash) {
bool Database::get(const std::string& key, dbEntry& entry) { bool Database::get(const std::string& key, dbEntry& entry) {
std::string sql; std::string sql;
if (key.find(':') != std::string::npos) { if (key.find(':') != std::string::npos) {
// Query by label:tag // Query by label:tag - search for exact match in the JSON array
sql = "SELECT hash, labeltags, metadata FROM objects WHERE labeltags LIKE ?;"; sql = "SELECT hash, labeltags, metadata FROM objects WHERE json_array_length(labeltags) > 0 AND EXISTS (SELECT 1 FROM json_each(labeltags) WHERE value = ?);";
} else { } else {
// Query by hash // Query by hash
sql = "SELECT hash, labeltags, metadata FROM objects WHERE hash = ?;"; sql = "SELECT hash, labeltags, metadata FROM objects WHERE hash = ?;";
@@ -198,9 +198,8 @@ bool Database::get(const std::string& key, dbEntry& entry) {
} }
if (key.find(':') != std::string::npos) { if (key.find(':') != std::string::npos) {
// Create JSON array pattern for LIKE query // For label:tag queries, bind the exact label:tag string
std::string labeltag_pattern = "%\"" + key + "\"%"; sqlite3_bind_text(stmt, 1, key.c_str(), -1, SQLITE_STATIC);
sqlite3_bind_text(stmt, 1, labeltag_pattern.c_str(), -1, SQLITE_STATIC);
} else { } else {
sqlite3_bind_text(stmt, 1, key.c_str(), -1, SQLITE_STATIC); sqlite3_bind_text(stmt, 1, key.c_str(), -1, SQLITE_STATIC);
} }