Skip to content

Commit

Permalink
Don't upload to S3 if local cache exists (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinbui authored Sep 24, 2024
1 parent acf949a commit 64143c0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/backends/s3.bash
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ function restore() {

function cache() {
TAR_FILE="${CACHE_KEY}.${BK_TAR_EXTENSION}"
if [ "${BK_CACHE_SAVE_CACHE}" == "true" ]; then
TAR_FILE="${BK_CACHE_LOCAL_PATH}/${TAR_FILE}"
fi
BUCKET="${BUILDKITE_PLUGIN_CACHE_S3_BUCKET}/${BUILDKITE_ORGANIZATION_SLUG}/$(pipeline_slug)"
TAR_TARGETS=""

Expand All @@ -144,7 +147,6 @@ function cache() {
fi

cache_locating "${TAR_TARGETS}"
TAR_FILE="${CACHE_KEY}.${BK_TAR_EXTENSION}"

if [ $BK_ALWAYS_CACHE == "true" ]; then
echo -e "${BK_LOG_PREFIX}:file_cabinet::close: Removing previously found cache ${TAR_FILE} since always is true."
Expand All @@ -157,5 +159,4 @@ function cache() {
mv -f "${TMP_FILE}" "${TAR_FILE}"
aws s3 cp ${BK_CUSTOM_AWS_ARGS} "${TAR_FILE}" "s3://${BUCKET}/${TAR_FILE}"
fi
rm -f "${TAR_FILE}"
}

0 comments on commit 64143c0

Please sign in to comment.