diff options
author | Dave Reisner <d@falconindy.com> | 2010-06-14 20:31:56 -0400 |
---|---|---|
committer | Dave Reisner <d@falconindy.com> | 2010-06-14 20:31:56 -0400 |
commit | f7f2723a2cb537b52e83ab383b71db8179f8b05a (patch) | |
tree | b68039f4980097ee94284332118a9ebe9e8eb438 | |
parent | ebbf701f966205d5820b1a3ccaf7c73117282666 (diff) | |
download | squashfu-f7f2723a2cb537b52e83ab383b71db8179f8b05a.tar.gz |
restore: fix glaring error which hid a possible restore and created a phony one
-rwxr-xr-x | squashfu | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -345,17 +345,20 @@ action_restore () { mount_squash || die "Failed to mount seed" IFS=$'\n' read -r -d $'\0' -a results < <(find $BINS_DIR/*/$(dirname $1)/$(basename $1) -maxdepth 0 2>/dev/null) - [[ -e "$SQUASH_MOUNT/$1" ]] && results[0]="$SQUASH_MOUNT/$1" - - [[ ${#results[@]} -eq 0 && ! -e $seedfile ]] && unmount_squash && die "Target not found: '$1'" - local restore_type=$(stat -c %F ${results[0]}) declare -a snaps - [[ -n ${results[0]} ]] && snaps[0]=$(stat -c %Z ${results[0]}) + [[ -e "$SQUASH_MOUNT/$1" ]] && snaps[0]=$(stat -c %Z "$SQUASH_MOUNT/$1") + + if [[ -z ${snaps[0]} && ${#results[@]} -eq 0 ]]; then + unmount_squash + die "Target not found: '$1'" + fi + + local restore_type=$(stat -c %F ${results[0]}) info "Found $(basename $1) in the following backups:" - [[ -n ${results[0]} ]] && printf " 0\t%s\n" "$(date --date=@${snaps[0]})" - for result in "${results[@]:1}"; do + [[ -n ${snaps[0]} ]] && printf " 0\t%s\n" "$(date --date=@${snaps[0]})" + for result in "${results[@]}"; do local bin=$(sed -n "s|$BINS_DIR/\([0-9]*\)$1|\1|p" <<< "$result") local bkupdate=$(sed -n "s|^$bin:\([0-9]*\)$|\1|p" $BINVENTORY) snaps[$bin]=$bkupdate |