From 1c9852168c01e358d4013672997a1ce3c3b7e3ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=B0=8F=E7=99=BD?= <296015668@qq.com> Date: Thu, 18 Jul 2024 21:00:02 +0800 Subject: [PATCH] feat: support zstd as archive format --- scripts/0_prepare.sh | 5 +++-- scripts/3_load_images.sh | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/0_prepare.sh b/scripts/0_prepare.sh index 52cc6e55..7fc397b1 100644 --- a/scripts/0_prepare.sh +++ b/scripts/0_prepare.sh @@ -59,7 +59,7 @@ function prepare_image_files() { images=$(get_images) for image in ${images}; do - filename=$(basename "${image}").tar + filename=$(basename "${image}").zst image_path="${IMAGE_DIR}/${filename}" md5_filename=$(basename "${image}").md5 md5_path="${IMAGE_DIR}/${md5_filename}" @@ -83,7 +83,8 @@ function prepare_image_files() { fi fi echo "$(gettext 'Save image') ${image} -> ${image_path}" - docker save -o "${image_path}" "${image}" & + # docker save -o "${image_path}" "${image}" & + docker save "${image}" | zstd -f -q -o "${image_path}" & echo "${image_id}" >"${md5_path}" & done wait diff --git a/scripts/3_load_images.sh b/scripts/3_load_images.sh index dde6f0a4..ae8bf7c5 100755 --- a/scripts/3_load_images.sh +++ b/scripts/3_load_images.sh @@ -10,7 +10,7 @@ IMAGE_DIR="images" function load_image_files() { images=$(get_images) for image in ${images}; do - filename=$(basename "${image}").tar + filename=$(basename "${image}").zst filename_windows=${filename/:/_} if [[ -f ${IMAGE_DIR}/${filename_windows} ]]; then filename=${filename_windows} @@ -39,7 +39,7 @@ function load_image_files() { } function main() { - if [[ -d "${IMAGE_DIR}" && $(find "${IMAGE_DIR}" -type f -name "*.tar" -print -quit 2>/dev/null) ]]; then + if [[ -d "${IMAGE_DIR}" && $(find "${IMAGE_DIR}" -type f -name "*.zst" -print -quit 2>/dev/null) ]]; then load_image_files else pull_images