From 31a6dff10dd3d818e4e129943582b0cca9957755 Mon Sep 17 00:00:00 2001 From: Ronald Ip Date: Tue, 13 Nov 2012 14:50:17 +0000 Subject: [PATCH] Added a routine in `bin/compile` to clean unused cached bundles (older than 30 days). Added Tests for cache pruning. --- bin/compile | 6 +++++- test/compile_test.sh | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/bin/compile b/bin/compile index 907a02759..02319dac9 100755 --- a/bin/compile +++ b/bin/compile @@ -60,8 +60,12 @@ shopt -s dotglob mkdir -p $BUILD_DIR $CACHE_DIR ${BUNDLE_DIR} ${BUILD_DIR}/local ${BUILD_DIR}/vendor/bin ${COMPOSER_HOME} -echo "-----> Fetching Manifest" pushd ${BUNDLE_DIR} > /dev/null + +echo "-----> Cleaning Unused Cached Bundles" +find . -type f -atime +30 -delete | indent + +echo "-----> Fetching Manifest" curl --silent --max-time 60 -O --location $MANIFEST_URL # Nginx diff --git a/test/compile_test.sh b/test/compile_test.sh index 16ba2a21b..778b73617 100644 --- a/test/compile_test.sh +++ b/test/compile_test.sh @@ -72,6 +72,16 @@ testCachedCompile() assertTrue "newrelic-daemon should be executable" "[ -x ${BUILD_DIR}/local/bin/newrelic-daemon ]" } +testCompileCachePrune() +{ + mkdir -p ${CACHE_DIR}/bundles + touch -amt '197001011234' ${CACHE_DIR}/bundles/delete_me.txt + compile + + assertCaptured "Cleaning Unused Cached Bundles" + assertFalse "delete_me.txt should be deleted" "[ -e ${CACHE_DIR}/bundles/delete_me.txt ]" +} + testCompileComposer() {