Do not send unneeded files to S3 and also delete old files from it

This commit is contained in:
Renato Botelho do Couto 2019-09-02 15:14:49 -03:00
parent 51bb83d8cd
commit 64290b3c75

View File

@ -1325,6 +1325,7 @@ finish() {
pkg_repo_rsync() {
local _repo_path_param="${1}"
local _ignore_final_rsync="${2}"
local _aws_sync_cmd="aws s3 sync --quiet --exclude '.real*/*' --exclude '.latest/*'"
if [ -z "${_repo_path_param}" -o ! -d "${_repo_path_param}" ]; then
return
@ -1462,7 +1463,17 @@ pkg_repo_rsync() {
echo -n ">>> Sending updated packages to AWS ${PKG_FINAL_S3_PATH}... " | tee -a ${_logfile}
if script -aq ${_logfile} ssh -p ${PKG_FINAL_RSYNC_SSH_PORT} \
${PKG_FINAL_RSYNC_USERNAME}@${_pkg_final_rsync_hostname} \
"aws s3 sync --quiet ${_repo} ${PKG_FINAL_S3_PATH}/$(basename ${_repo})"; then
"${_aws_sync_cmd} ${_repo} ${PKG_FINAL_S3_PATH}/$(basename ${_repo})"; then
echo "Done!" | tee -a ${_logfile}
else
echo "Failed!" | tee -a ${_logfile}
echo ">>> ERROR: An error occurred sending files to AWS S3"
print_error_pfS
fi
echo -n ">>> Cleaning up packages at AWS ${PKG_FINAL_S3_PATH}... " | tee -a ${_logfile}
if script -aq ${_logfile} ssh -p ${PKG_FINAL_RSYNC_SSH_PORT} \
${PKG_FINAL_RSYNC_USERNAME}@${_pkg_final_rsync_hostname} \
"${_aws_sync_cmd} --delete ${_repo} ${PKG_FINAL_S3_PATH}/$(basename ${_repo})"; then
echo "Done!" | tee -a ${_logfile}
else
echo "Failed!" | tee -a ${_logfile}