This commit is contained in:
@@ -237,7 +237,7 @@ bool Database::get(const std::string& hash_or_labeltag, dbEntry& entry) {
|
|||||||
|
|
||||||
// try with a :latest tag
|
// try with a :latest tag
|
||||||
std::string with_latest = hash_or_labeltag + ":latest";
|
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) {
|
bool Database::list(std::vector<dbEntry>& entries) {
|
||||||
|
@@ -117,7 +117,7 @@ title "2: Check sos hash matches"
|
|||||||
# check the hash matches.
|
# check the hash matches.
|
||||||
CMD="${HOSTURL}/hash/${BASE_TAG}:test1"
|
CMD="${HOSTURL}/hash/${BASE_TAG}:test1"
|
||||||
echo "checking hash via ${CMD}"
|
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}"
|
[ "${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 the object
|
||||||
DOWNLOAD_FILE="${TEST_FILE}.downloaded"
|
DOWNLOAD_FILE="${TEST_FILE}.downloaded"
|
||||||
echo "downloading ${OBJECT_HASH} to ${DOWNLOAD_FILE}1"
|
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"
|
die "Command failed: curl -s ${HOSTURL}/${OBJECT_HASH} -o ${DOWNLOAD_FILE}1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# download the object again via the label:tag
|
# download the object again via the label:tag
|
||||||
echo "downloading ${BASE_TAG}:test1 to ${DOWNLOAD_FILE}2"
|
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"
|
die "failed to download ${BASE_TAG}:test1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ fi
|
|||||||
|
|
||||||
# download via the label:tag
|
# download via the label:tag
|
||||||
echo "downloading ${LABELTAG} to ${DOWNLOAD_FILE}3"
|
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}"
|
die "failed to download ${LABELTAG}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -311,6 +311,18 @@ UPLOAD_RESPONSE=$(curl -X PUT \
|
|||||||
|
|
||||||
FIRST_HASH=$(echo "${UPLOAD_RESPONSE}" | jq -r '.hash')
|
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
|
# Store first version's metadata before uploading second version
|
||||||
FIRST_METADATA=$(curl -s "${HOSTURL}/meta/${FIRST_HASH}")
|
FIRST_METADATA=$(curl -s "${HOSTURL}/meta/${FIRST_HASH}")
|
||||||
echo "First version metadata response: ${FIRST_METADATA}"
|
echo "First version metadata response: ${FIRST_METADATA}"
|
||||||
|
Reference in New Issue
Block a user