Skip to content

Commit 3ac28f7

Browse files
author
buildplan
committed
Improved Recycle Bin Date Validation
1 parent 8474227 commit 3ac28f7

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

backup_script.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -462,13 +462,11 @@ run_recycle_bin_cleanup() {
462462
local threshold_timestamp
463463
threshold_timestamp=$(date -d "$retention_days days ago" +%s)
464464
while IFS= read -r folder; do
465-
if [[ "$folder" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
466-
local folder_timestamp
467-
folder_timestamp=$(date -d "$folder" +%s)
468-
if (( folder_timestamp < threshold_timestamp )); then
469-
folders_to_delete+="${folder}"$'\n'
470-
fi
471-
fi
465+
if [[ "$folder" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]] && folder_timestamp=$(date -d "$folder" +%s 2>/dev/null); then
466+
if (( folder_timestamp < threshold_timestamp )); then
467+
folders_to_delete+="${folder}"$'\n'
468+
fi
469+
fi
472470
done <<< "$all_folders"
473471
if [[ -n "$folders_to_delete" ]]; then
474472
log_message "Removing old recycle bin folders:"

0 commit comments

Comments
 (0)