Skip to content

Commit e2832f7

Browse files
committed
feat(cache): 添加缓存文件压缩和解压脚本
1 parent 1cdc7ba commit e2832f7

5 files changed

Lines changed: 37 additions & 0 deletions

File tree

extract_ths_tool_cache/compress.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# 定义目标文件夹和输出文件名前缀
4+
TARGET_DIR="tool_cache"
5+
OUTPUT_PREFIX="extract_ths_tool_cache/tool_cache.tar.gz.part_"
6+
SIZE_LIMIT="50m"
7+
8+
echo "正在压缩并切分 $TARGET_DIR ..."
9+
10+
# tar -c: 创建
11+
# -z: gzip压缩
12+
# -f -: 将结果输出到标准输出流
13+
# split -b: 按大小切分
14+
# -: 从标准输入流读取
15+
tar -czf - "$TARGET_DIR" --exclude='.DS_Store' | split -b $SIZE_LIMIT - "$OUTPUT_PREFIX"
16+
17+
echo "压缩完成!生成的切分文件如下:"
18+
ls -lh ${OUTPUT_PREFIX}*

extract_ths_tool_cache/extract.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
# 定义切分文件的前缀
4+
TARGET_DIR="tool_cache"
5+
INPUT_PREFIX="extract_ths_tool_cache/tool_cache.tar.gz.part_"
6+
7+
# 检查是否有分卷文件
8+
if ! ls ${INPUT_PREFIX}* 1> /dev/null 2>&1; then
9+
echo "错误:未发现分卷文件 ${INPUT_PREFIX}*"
10+
exit 1
11+
fi
12+
13+
echo "正在合并并解压文件..."
14+
15+
# cat: 合并所有分卷
16+
# tar -x: 解压
17+
cat ${INPUT_PREFIX}* | tar -xzf -
18+
19+
echo "解压完成!文件夹 '$TARGET_DIR' 已还原。"
50 MB
Binary file not shown.
50 MB
Binary file not shown.
6.82 MB
Binary file not shown.

0 commit comments

Comments
 (0)