Skip to content

Commit

Permalink
make the console notifiacation code more robust - closes #649
Browse files Browse the repository at this point in the history
Signed-off-by: Jiri Moskovcak <jmoskovc@redhat.com>
Signed-off-by: Richard Marko <rmarko@redhat.com>

rmarko: replaced tabs with spaces
  • Loading branch information
Jiri Moskovcak authored and Richard Marko committed May 9, 2013
1 parent 2ca3a0b commit 042b95d
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/cli/abrt-console-notification.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
LPATHDIR="$HOME/.cache/abrt"
SINCEFILE="$LPATHDIR/lastnotification"
TMPPATH=`mktemp --tmpdir="$LPATHDIR" lastnotification.XXXXXXXX`

if [ ! -f "$LPATHDIR" ]; then
mkdir -p "$LPATHDIR"
fi

TMPPATH=`mktemp --tmpdir="$LPATHDIR" lastnotification.XXXXXXXX 2> /dev/null`

SINCE=0
if [ -f $SINCEFILE ]; then
SINCE=`cat $SINCEFILE`
if [ -f "$SINCEFILE" ]; then
SINCE=`cat $SINCEFILE 2> /dev/null`
fi

# always update the lastnotification
date +%s > "$TMPPATH"
mv "$TMPPATH" "$SINCEFILE"
if [ -f "$TMPPATH" ]; then
date +%s > "$TMPPATH"
mv "$TMPPATH" "$SINCEFILE"
fi

abrt-cli status --since="$SINCE" 2> /dev/null

0 comments on commit 042b95d

Please sign in to comment.