:-'Generic Commit'
All checks were successful
Build-Test-Publish / Build (push) Successful in 1m8s

This commit is contained in:
Your Name
2025-05-30 23:57:26 +12:00
parent fd6cc5bef4
commit 439ad79524
2 changed files with 17 additions and 5 deletions

View File

@@ -237,7 +237,7 @@ bool Database::get(const std::string& hash_or_labeltag, dbEntry& entry) {
// try with a :latest tag
std::string with_latest = hash_or_labeltag + ":latest";
return (run_sql_text("SELECT hash, labeltags, metadata FROM objects WHERE hash = ?;", with_latest, entry));
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 = ?);", with_latest, entry));
}
bool Database::list(std::vector<dbEntry>& entries) {

View File

@@ -117,7 +117,7 @@ title "2: Check sos hash matches"
# check the hash matches.
CMD="${HOSTURL}/hash/${BASE_TAG}:test1"
echo "checking hash via ${CMD}"
CHECK_HASH=$(curl -s "${CMD}" | jq -r '.hash')
CHECK_HASH=$(curl --fail-with-body -s "${CMD}" | jq -r '.hash')
[ "${OBJECT_HASH}" != "${CHECK_HASH}" ] && die "hash does not match: ${OBJECT_HASH} != ${CHECK_HASH}"
@@ -131,13 +131,13 @@ echo "md5sum of ${TEST_FILE} is ${MD5SUM}"
# download the object
DOWNLOAD_FILE="${TEST_FILE}.downloaded"
echo "downloading ${OBJECT_HASH} to ${DOWNLOAD_FILE}1"
if ! curl -s "${HOSTURL}/${OBJECT_HASH}" -o "${DOWNLOAD_FILE}1"; then
if ! curl --fail-with-body -s "${HOSTURL}/${OBJECT_HASH}" -o "${DOWNLOAD_FILE}1"; then
die "Command failed: curl -s ${HOSTURL}/${OBJECT_HASH} -o ${DOWNLOAD_FILE}1"
fi
# download the object again via the label:tag
echo "downloading ${BASE_TAG}:test1 to ${DOWNLOAD_FILE}2"
if ! curl -s "${HOSTURL}/${BASE_TAG}:test1" -o "${DOWNLOAD_FILE}2"; then
if ! curl --fail-with-body -s "${HOSTURL}/${BASE_TAG}:test1" -o "${DOWNLOAD_FILE}2"; then
die "failed to download ${BASE_TAG}:test1"
fi
@@ -195,7 +195,7 @@ fi
# download via the label:tag
echo "downloading ${LABELTAG} to ${DOWNLOAD_FILE}3"
if ! curl -s "${HOSTURL}/${LABELTAG}" -o "${DOWNLOAD_FILE}3"; then
if ! curl --fail-with-body -s "${HOSTURL}/${LABELTAG}" -o "${DOWNLOAD_FILE}3"; then
die "failed to download ${LABELTAG}"
fi
@@ -311,6 +311,18 @@ UPLOAD_RESPONSE=$(curl -X PUT \
FIRST_HASH=$(echo "${UPLOAD_RESPONSE}" | jq -r '.hash')
# check downloading without tag!
echo "downloading ${BASE_TAG} to ${DOWNLOAD_FILE}4"
if ! curl -s --fail-with-body "${HOSTURL}/${BASE_TAG}" -o "${DOWNLOAD_FILE}4"; then
die "failed to download ${BASE_TAG}"
fi
# get md5sum of the downloaded file
MD5SUM_DOWNLOADED4=$(md5sum "${DOWNLOAD_FILE}4" | awk '{print $1}')
MD5SUM_ORIGINAL=$(md5sum "${SCRIPT_DIR}/${SCRIPT_NAME}" | awk '{print $1}')
[ "${MD5SUM_ORIGINAL}" != "${MD5SUM_DOWNLOADED4}" ] && die "md5sums do not match"
# Store first version's metadata before uploading second version
FIRST_METADATA=$(curl -s "${HOSTURL}/meta/${FIRST_HASH}")
echo "First version metadata response: ${FIRST_METADATA}"