From 57c98073b7d482cd42ad5df8bf16a70ded3f7d15 Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Thu, 3 Aug 2017 19:29:39 +0300 Subject: [PATCH] Refactor rootfs cache file number limit --- lib/configuration.sh | 1 + lib/general.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/configuration.sh b/lib/configuration.sh index caa498eb03..32ef44cffe 100644 --- a/lib/configuration.sh +++ b/lib/configuration.sh @@ -20,6 +20,7 @@ EXIT_PATCHING_ERROR="" # exit patching if failed HOST="$(echo "$BOARD" | cut -f1 -d-)" # set hostname to the board ROOTFSCACHE_VERSION=3 [[ -z $DISPLAY_MANAGER ]] && DISPLAY_MANAGER=nodm +ROOTFS_CACHE_MAX=8 # max number of rootfs cache, older ones will be cleaned up [[ -z $ROOTFS_TYPE ]] && ROOTFS_TYPE=ext4 # default rootfs type is ext4 [[ "ext4 f2fs btrfs nfs fel" != *$ROOTFS_TYPE* ]] && exit_with_error "Unknown rootfs type" "$ROOTFS_TYPE" diff --git a/lib/general.sh b/lib/general.sh index f0a0eafce9..aba174202a 100644 --- a/lib/general.sh +++ b/lib/general.sh @@ -71,7 +71,7 @@ cleaning() oldcache) if [[ -d $SRC/cache/rootfs && $(ls -1 $SRC/cache/rootfs | wc -l) -gt 6 ]]; then display_alert "Cleaning" "rootfs cache (old)" "info" - (cd $SRC/cache/rootfs; ls -t | sed -e "1,6d" | xargs -d '\n' rm -f) + (cd $SRC/cache/rootfs; ls -t | sed -e "1,${ROOTFS_CACHE_MAX}d" | xargs -d '\n' rm -f) fi ;; esac