Merge pull request #23 from robru/simplify-logfiles

Simplify logfile parsing and drop unreachable codepath.
This commit is contained in:
Laurent
2013-12-06 08:39:40 -08:00
+4 -17
View File
@@ -221,32 +221,19 @@ while : ; do
# -----------------------------------------------------------------------------
# TODO: find better way to check for out of space condition without parsing log.
grep --quiet "No space left on device (28)" "$LOG_FILE"
NO_SPACE_LEFT="$?"
if [ "$NO_SPACE_LEFT" != "0" ]; then
# This error might also happen if there is no space left
grep --quiet "Result too large (34)" "$LOG_FILE"
NO_SPACE_LEFT="$?"
fi
NO_SPACE_LEFT="$(grep "No space left on device (28)\|Result too large (34)" "$LOG_FILE")"
rm -- "$LOG_FILE"
if [ "$NO_SPACE_LEFT" == "0" ]; then
if [ -n "$NO_SPACE_LEFT" ]; then
fn_log_warn "No space left on device - removing oldest backup and resuming."
BACKUP_FOLDER_COUNT=$(fn_find_backups | wc -l)
if [[ "$BACKUP_FOLDER_COUNT" -lt "2" ]]; then
if [[ "$(fn_find_backups | wc -l)" -lt "2" ]]; then
fn_log_error "No space left on device, and no old backup to delete."
exit 1
fi
OLD_BACKUP_PATH="$(fn_find_backups | tail -n 1)"
if [ -z "$OLD_BACKUP_PATH" ]; then
fn_log_error "No space left on device, and cannot get path to oldest backup to delete."
exit 1
fi
fn_expire_backup "$OLD_BACKUP_PATH"
fn_expire_backup "$(fn_find_backups | tail -n 1)"
# Resume backup
continue