File tree 2 files changed +2
-24
lines changed
2 files changed +2
-24
lines changed Original file line number Diff line number Diff line change 77
77
cat " ${refs} "
78
78
}
79
79
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
-
100
80
# this will redirect stderr(2) to stderr file.
101
81
{
102
82
source " ${REGISTRY_LAUNCHER} "
@@ -178,9 +158,7 @@ if [ ${#ENV_EXPANSIONS[@]} -ne 0 ]; then
178
158
fi
179
159
180
160
if [ -n " $OUTPUT " ]; then
181
-
182
- " ${CRANE} " pull " ${REF} " " ./${OUTPUT} " --format=oci
183
- gc " ${REF} "
161
+ " ${CRANE} " pull " ${REF} " " ./${OUTPUT} " --format=oci --prune
184
162
stop_registry " ${STORAGE_DIR} "
185
163
fi
186
164
Original file line number Diff line number Diff line change 37
37
38
38
function stop_registry() {
39
39
local storage_dir=" $1"
40
- rm -r " ${storage_dir}/.uploads"
40
+ rm -rf " ${storage_dir}/.uploads"
41
41
rm -r " ${storage_dir}/config.json"
42
42
}
You can’t perform that action at this time.
0 commit comments