Skip to content

Commit 125c19c

Browse files
committed
use prune
1 parent c59f256 commit 125c19c

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

oci/private/image.sh.tpl

+1-23
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,6 @@ EOF
7777
cat "${refs}"
7878
}
7979

80-
# removes unreferenced blobs from oci-layout and normalizes index.json
81-
function gc() {
82-
local ref="$1"
83-
local digest=$("${CRANE}" digest "${ref}")
84-
local blobs=($("${CRANE}" manifest "${ref}" | "${JQ}" -r --arg digest "$digest" '([.layers[].digest] + [.config.digest, $digest]) | flatten | .[]'))
85-
for blob_dir in ${STORAGE_DIR}/blobs/* ; do
86-
local algo="$(basename ${blob_dir})"
87-
for blob_path in ${blob_dir}/* ; do
88-
local blob_digest="$(basename ${blob_path})"
89-
local hash="${algo}:${blob_digest}"
90-
if ! [[ "${blobs[@]}" =~ "$hash" ]]; then
91-
rm $blob_path
92-
fi
93-
done
94-
done
95-
mv "${STORAGE_DIR}/index.json" "${STORAGE_DIR}/temp.json"
96-
"${JQ}" --arg digest "$digest" '.manifests |= [map(select(.digest == $digest and .annotations == null))[0]]' "${STORAGE_DIR}/temp.json" > "${STORAGE_DIR}/index.json"
97-
rm "${STORAGE_DIR}/temp.json"
98-
}
99-
10080
# this will redirect stderr(2) to stderr file.
10181
{
10282
source "${REGISTRY_LAUNCHER}"
@@ -178,9 +158,7 @@ if [ ${#ENV_EXPANSIONS[@]} -ne 0 ]; then
178158
fi
179159

180160
if [ -n "$OUTPUT" ]; then
181-
182-
"${CRANE}" pull "${REF}" "./${OUTPUT}" --format=oci
183-
gc "${REF}"
161+
"${CRANE}" pull "${REF}" "./${OUTPUT}" --format=oci --prune
184162
stop_registry "${STORAGE_DIR}"
185163
fi
186164

oci/private/registry/zot_launcher.sh.tpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ EOF
3737

3838
function stop_registry() {
3939
local storage_dir="$1"
40-
rm -r "${storage_dir}/.uploads"
40+
rm -rf "${storage_dir}/.uploads"
4141
rm -r "${storage_dir}/config.json"
4242
}

0 commit comments

Comments
 (0)