From 3dbed651e51204bccd6fbc116f474a307444a327 Mon Sep 17 00:00:00 2001 From: thuanle Date: Wed, 22 Jul 2026 00:45:17 +0700 Subject: [PATCH] Arch pkg cache: remove partial download-* files before pacman -Sc pacman -Sc errors with 'could not open file .../download-XXXX: Error reading fd 7' on leftover incomplete downloads. Find and remove them (with confirm) first, then run paccache/pacman -Sc cleanly. Co-Authored-By: Claude --- cleanup-server | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cleanup-server b/cleanup-server index 3ac92dc..7746a6c 100755 --- a/cleanup-server +++ b/cleanup-server @@ -255,6 +255,17 @@ step_pkg_cache() { arch) local d="/var/cache/pacman/pkg" [ -d "$d" ] && sudo du -sh "$d" + # Xóa file download tạm (incomplete) — pacman -Sc báo lỗi fd 7 với chúng. + local partial pcount + partial=$(sudo find "$d" -maxdepth 1 -type f -name 'download-*' 2>/dev/null) + if [ -n "$partial" ]; then + pcount=$(printf '%s\n' "$partial" | grep -c .) + echo " ${C_WARN}✗ ${pcount} file download tạm (incomplete).${C_RESET}" + if confirm_yn "Xóa file download-* tạm?"; then + printf '%s\n' "$partial" | xargs sudo rm -f -- + echo "${C_OK} ✓ Đã xóa file tạm.${C_RESET}" + fi + fi if command -v paccache >/dev/null 2>&1; then sudo paccache -dk2 # dry-run xem trước if confirm_yn "paccache -rk2 (giữ 2 bản)?"; then