From fb2a3585d48e7ac20336c71f7adcbfb97d42ed09 Mon Sep 17 00:00:00 2001 From: BeauTroll <-> Date: Wed, 17 Dec 2025 19:43:04 +0100 Subject: [PATCH] Improve disk space estimation messages in backup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add compressed size estimation and better error handling: - Show both uncompressed (for safety) and estimated compressed size - Handle calculation failure gracefully with clear message - Estimate compression ratio at ~90% (divide by 10) - Add conditional check to prevent arithmetic errors Example output: - Espace requis (non compressé + 20%): 1.7GiB - Espace estimé après compression: 170MiB - Archive finale: 55MiB (actual result) This helps users understand why the required space seems larger than the final backup size (compression factor). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- scripts/backup.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/backup.sh b/scripts/backup.sh index ef0d630..fa06f7e 100755 --- a/scripts/backup.sh +++ b/scripts/backup.sh @@ -106,7 +106,14 @@ if [ -z "$AVAILABLE_SPACE" ]; then exit 1 fi -log "INFO" "Espace requis (estimé): $(numfmt --to=iec-i --suffix=B "$REQUIRED_SPACE" 2>/dev/null || echo "$REQUIRED_SPACE bytes")" +# Calculer estimation avec compression (ratio moyen ~90%) +if [ "$REQUIRED_SPACE" -gt 0 ] 2>/dev/null; then + ESTIMATED_COMPRESSED=$((REQUIRED_SPACE / 10)) + log "INFO" "Espace requis (non compressé + 20%): $(numfmt --to=iec-i --suffix=B "$REQUIRED_SPACE" 2>/dev/null || echo "$REQUIRED_SPACE bytes")" + log "INFO" "Espace estimé après compression: $(numfmt --to=iec-i --suffix=B "$ESTIMATED_COMPRESSED" 2>/dev/null || echo "$ESTIMATED_COMPRESSED bytes")" +else + log "INFO" "Espace requis: Impossible à calculer (utilisation du fallback)" +fi log "INFO" "Espace disponible: $(numfmt --to=iec-i --suffix=B "$AVAILABLE_SPACE" 2>/dev/null || echo "$AVAILABLE_SPACE bytes")" # Comparaison sécurisée avec validation